IntroductionA virtual private network also known as a VPN is a private network that extends across a public network or internet. It enables users to send and receive data across shared or public networks as if their computing devices were directly connected to the private network. From all of the possible options, the most optimal ones are between PPTP and OpenVPN.
A Point-To-Point Tunneling Protocol (PPTP) allows you to implement your own VPN very quickly, and is compatible with most mobile devices. Even though PPTP is less secure than OpenVPN, it is also faster and uses less CPU resources.
RequirementsIn Time4VPS Standard VPS PPTP module is not enabled by default and it can be only used in our KVM Linux VPS.
InstallationAfter PPTP module is enabled from our side we can start installing it:
apt-get install pptpd
Now you should edit /etc/pptpd.conf
nano /etc/pptpd.conf
and add the following lines:
localip 10.0.0.1
remoteip 10.0.0.100-200
Next, you should setup authentication for PPTP by adding users and passwords:
nano /etc/ppp/chap-secrets
It should look like this (we added one test user):
# Secrets for authentication using CHAP
# client server secret IP addresses
vpnuser pptpd password *
Where client is the username, server is type of service – pptpd for our example, secret is the password, and IP addresses specifies which IP address may authenticate. By setting ‘*’ in IP addresses field, you specify that you would accept username/password pair for any IP.
Adding DNS serversNow we need to add DNS servers to /etc/ppp/pptpd-options. Open file:
nano /etc/ppp/pptpd-options
And uncomment (delete "#" symbols in the beginning of the lines) these lines:
ms-dns 8.8.8.8
ms-dns 8.8.4.4
After this restart PPTPD:
service pptpd restart
Setup ForwardingTo enable IPv4 forward change /etc/sysctl.conf file:
nano /etc/sysctl.conf
By uncommenting the line:
net.ipv4.ip_forward=1
To make changes active, run:
sysctl -p
Adding iptablesExecute this command to add iptables rule:
iptables -t nat -A POSTROUTING -o venet0 -j MASQUERADE
ConlusionYou are done. Just reboot your server and you should be able to connect to using PPTPD and send all your traffic through this server.
Comments
systemctl enable pptpd
iptables -t nat -A POSTROUTING -o venet0 -j MASQUERADE
iptables-save > /etc/iptables.up.rules
Create file:
nano /etc/network/if-pre-up.d/iptables
File Contents:
#!/bin/sh iptables-restore < /etc/iptables.up.rules
Save the file
chmod +x /etc/network/if-pre-up.d/iptables
reboot