Installation and Configuration of PPTP VPN on Ubuntu 18.04
Ever wonder that how you can create your VPN server using the PPTP protocol. Well this is your lucky as in this article we will install and configure PPTP VPN on ubuntu.
Installation
First of all you need to update your ubuntu server.
# sudo apt update -y
Next you need to install the package of PPTP. By default ubuntu repository got the necessary dependencies for this package. So to install the package just run the below command.
# sudo apt-get install pptpd
Configuration
Then we will configuring the pptpd.
# sudo nano /etc/pptpd.conf
At the bottom of the /etc/pptpd.conf
you need to add the below two lines.
localip 192.168.0.1
remoteip 192.168.0.100-200
Local IP: will be your server Public IP address
Remote IP: When the user will connect it will be assigned an IP which you can range them here
Next we need to configure the DNS so when the clients connect to the server they can use this VPN.
# sudo nano /etc/ppp/pptpd-options
ms-dns 8.8.8.8
ms-dns 8.8.4.4
Next we need to add a VPN user in /etc/ppp/chap-secrets
# sudo nano /etc/ppp/chap-secrets
# client server secret IP addresses
teclime * myPassword *
Client: which stands here for username
Server: we have set it any you can name it whatever your desire
Secret: Password for the user
IP Address: To allow ALL IP
After that we need to start the service of pptpd
# /etc/init.d/pptpd restart
And enable the service so when the servers bootsup the service will be automatically started
# systemctl enable pptpd
Setup IP Forwarding
We need to enable IP forwarding for the we need to goto /etc/sysctl.conf
# sudo nano /etc/sysctl.conf
net.ipv4.ip_forward=1 (uncomment this line)
Now run the below command for changes update.
# sudo sysctl -p
Next we need to add the rules in IP tables for NAT
# iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
# iptables -A FORWARD -p tcp --syn -s 192.168.0.0/24 -j TCPMSS --set-mss 1356
After that the iptables rules will flush when your server will be rebooted. For that we need to set a cronjob.
# crontab -e
@reboot /sbin/iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
@reboot /sbin/iptables -A FORWARD -p tcp --syn -s 192.168.0.0/24 -j TCPMSS --set-mss 1356
Next we need to check our VPN server from a windows client that it is accessible or not.
Now goto vpn settings in windows
Then click on the “Add a VPN Connection” and add the desired details
VPN Provider: Windows Builtin
Server IP: Public IP of the VPN Server
VPN Type: Select PPTP
After click on Save button you will connect on your VPN Connection and That’s it.