
Introduction
A Virtual Private Network (VPN) is a private network that extends over a public network, such as the internet, allowing users to send and receive data as if their devices were directly connected to the private network. Among the various VPN options available, PPTP and OpenVPN stand out as two of the most popular. While Point-To-Point Tunneling Protocol (PPTP) is less secure than OpenVPN, it is faster and requires fewer CPU resources, making it a quick and compatible choice, especially for mobile devices.
Requirements
For VPSHosting.lk Standard VPS, the PPTP module is not enabled by default and can only be used with our KVM Linux VPS.
Installation
Once the PPTP module is enabled on your server, you can proceed with the installation:
apt-get install pptpd
Next, you'll need to edit the configuration file located at /etc/pptpd.conf
:
nano /etc/pptpd.conf
Add the following lines to the file:
localip 10.0.0.1
remoteip 10.0.0.100-200
This configuration assigns a local IP address to the server and a range of IP addresses to remote clients.
Setting Up Authentication
To set up authentication for PPTP, you need to add users and their passwords by editing the chap-secrets
file:
nano /etc/ppp/chap-secrets
Add the following example entry:
# Secrets for authentication using CHAP
# client server secret IP addresses
vpnuser pptpd password *
In this configuration:
- client is the username,
- server is the service type (pptpd in this case),
- secret is the password,
- IP addresses specify which IP addresses may authenticate. The
*
allows any IP address to authenticate using the provided username and password.
Adding DNS Servers
To ensure your PPTP VPN uses the correct DNS servers, add them to the pptpd-options
file:
nano /etc/ppp/pptpd-options
Uncomment the following lines by removing the #
at the beginning:
ms-dns 8.8.8.8
ms-dns 8.8.4.4
After making these changes, restart the PPTP service:
service pptpd restart
Enabling IPv4 Forwarding
To enable IPv4 forwarding, modify the /etc/sysctl.conf
file:
nano /etc/sysctl.conf
Uncomment the line:
net.ipv4.ip_forward=1
Apply the changes by running:
sysctl -p
Adding IPTables Rules
To configure iptables for network address translation (NAT), execute the following command:
iptables -t nat -A POSTROUTING -o venet0 -j MASQUERADE
Conclusion
That’s it! Your server is now configured to use PPTP. After rebooting your server, you should be able to connect via PPTP and route all your traffic through this VPN.
This version retains all the technical details while improving the clarity and flow of the instructions.