This guide will help us install the PPTP VPN server on your VPS (virtual private server). PPTP is used to create a virtual private network over the internet. The main agenda of creating a PPTP VPN server on VPS is to transfer your data using a virtual ethernet interface that uses your VPS IP address.
This tunneling technology is compatible with several devices like desktop operating systems, mobile phones, and tablets. We will be using CentOS 7.8 as our host operating system.
Step 1: Clean Install
Always make sure you begin with a clean install by removing any previously installed packages:
yum remove -y pptpd ppp iptables --flush POSTROUTING --table nat iptables --flush FORWARD rm -rf /etc/pptpd.conf rm -rf /etc/ppp
Step 2: Installation
2.1: Install PPP & PPTPD
yum install ppp pptpd -y
2.2: Install IPtables-services
yum install iptables-services
2.3: Install Nano Editor
yum install nano -y
Or else simply type command
yum install ppp pptpd iptables-services nano -y to install all the packages at once.
You can install and use nano editor or vi editor depending on your command over these editor.
Now, we need to enable IP forwading, set internal IP addresses and point the DNS Servers that will be used by the pptp server:
mknod /dev/ppp c 108 0 echo 1 > /proc/sys/net/ipv4/ip_forward echo "mknod /dev/ppp c 108 0" >> /etc/rc.local
Step 3: Configurations
3.1: Edit IP setttings in /etc/pptpd.conf
echo "localip 172.16.36.1" >> /etc/pptpd.conf echo "remoteip 172.16.36.2-254" >> /etc/pptpd.conf
3.2: Settings in /etc/ppp/options.pptpd
echo "ms-dns 188.8.131.52" >> /etc/ppp/options.pptpd echo "ms-dns 184.108.40.206" >> /etc/ppp/options.pptpd
3.3: Enable network forwarding in /etc/sysctl.conf
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
Step 4: Assign username and password
Create your users credentials for the PPTP server. This credentials will be used to log in to the PPTP server on every client/device you connect from:
Your chap-secrets file should look like this:
# Secrets for authentication using CHAP # client server secret IP addresses username pptpd password *
Press ” CTRL + X ” followed by ” y ” and then ” Enter ” to save and close the file.
Step 5. Firewall configuration
You need to add the following iptables rules in order to open the correct ports and properly forward the data packets:
VPN rules (pptpd)
iptables -A INPUT -i eth0 -p tcp --dport 1723 -j ACCEPT iptables -A INPUT -i eth0 -p gre -j ACCEPT iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables -A FORWARD -p tcp -s 172.16.36.0/24 -j TCPMSS --syn --set-mss 1356
Now save and restart your iptables firewall:
service iptables save service iptables restart
Step 6: PPTP auto start configuration
To start PPTP Daemon automatically when rebooting next time, use the following command:
chkconfig iptables on chkconfig pptpd on
Note: Make sure you load your iptables after every reboot.
Step 7: Start PPTP VPN server
And then make sure to restart iptables and pptpd services.
service iptables start service pptpd start
Done with installation part, now its time to connect VPN that we have created.
Note: In case you have trouble connecting to VPN, then make sure that pptpd port is open in your router and to your IP address.
Your PPTP VPN server setup is now complete. You should now be able to login to your VPN server from any client: Windows PCs, Linux PCs, Android phones/tablets, or iPhone and iPad.
The log of the VPN server, by default, is combined with system log located at /var/log/messages.
Hope this tutorial is helpful and comment down if you have any query or issue.