First confirm uninstalling PPTPD and iptables
#apt-get Remove pptpd
Apt-get Autoremove pptpd
Apt-get Purge pptpd
#apt-get Remove iptables*
Apt-get Autoremove iptables*
Apt-get Purge iptables*
Next Install pptpd
Apt-get Install pptpd
Vi/etc/pptpd.conf
Fix the following two lines: where VPS_IP is the public IP of your VPS, can be viewed through the ifconfig command, 10.100.0.2-10 This is the IP segment assigned to the VPN user.
Localip vps_ip
Remoteip 10.100.0.2-10
Vi/etc/ppp/pptpd-options modify DNS settings, set as DNS for Google
Ms-dns 8.8.8.8
Ms-dns 8.8.4.4
Vi/etc/ppp/chap-secrets Set the VPN account number and password (* No limit)
user name, service, password, limit IP
lyf pptpd 123456 *
/ETC/INIT.D/PPTPD Restart Restart PPTPD service
Next, set the IPv4 forwarding switch for the system.
Vi/etc/sysctl.conf
net.ipv4.ip_forward=1, open the note on this line.
Run: sysctl-p Let the above fix take effect immediately
Next Install Iptables
Apt-get Install Iptables
Add a NAT (note here: venet0:0 refers to your VPS public IP NIC interface, can be viewed through ifconfig)
Iptables-t nat-a postrouting-s 10.100.0.0/24-o venet0:0-j Masquerade
Set the MTU to prevent the package from being too large
Iptables-a forward-s 10.100.0.0/24-p tcp-m tcp--tcp-flags syn,rst syn-j TCPMSS--SET-MSS 1200
Add a NAT (45.62.119.172 is the public IP of your VPS)
Iptables-t nat-a postrouting-s 10.100.0.0/24-j SNAT--to-source 45.62.119.172
Then save the iptables rule so that the rule is not lost after reboot:
Iptables-save >/etc/iptables-rules
Finally edit the network card file, load the card automatically when loading rules
Vi/etc/network/interfaces
at the end of the file, add: pre-up Iptables-restore </etc/iptables-rules
Built PPTP service on VPS Ubuntu