Setting up a PPTP server on Linux
On this page
Step 1: Install PPTP PackagesStep 2: Configure the PPTP ServerStep 3: Configure the PPTP ServerStep 4: Configure DNSStep 5: Enable IP ForwardingStep 6: Configure iptablesStep 7: Restart PPTPStep 1: Install PPTP Packages
Open the terminal and install the required PPTP packages by entering the following commands:
sudo apt update
sudo apt install pptpdStep 2: Configure the PPTP Server
Edit the settings file /etc/ppp/chap-secrets and add a user account that needs access to the VPN server.
nano /etc/ppp/chap-secretsInside the file, add the user account, specifying the username, password, and destination IP address. They should be separated by spaces as shown below:
# Secrets for authentication using CHAP
user1 pptpd password123 192.168.0.101Step 3: Configure the PPTP Server
PPTP server settings are stored in the configuration file /etc/pptpd.conf. Edit this file and add the following configuration:
nano /etc/pptpd.confAdd or modify the following parameters:
option /etc/ppp/pptpd-options
logwtmp
localip 192.168.0.1 # Local IP address of the server
remoteip 192.168.0.101-200 # Allowed range of IP addresses for clientsStep 4: Configure DNS
Configure DNS by editing the /etc/ppp/pptpd-options file. Add Google DNS:
nano /etc/ppp/pptpd-optionsAdd the following lines to the file:
ms-dns 8.8.8.8
ms-dns 8.8.4.4Step 5: Enable IP Forwarding
To ensure proper routing and connectivity of your VPN network, you need to enable IP forwarding. Execute the following command:
sudo nano /etc/sysctl.confAdd or modify the following parameter, net.ipv4.ip_forward, to a value of 1:
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1Save and close the file.
Then, apply the sysctl changes with this command:
sudo sysctl -pStep 6: Configure iptables
To complete the PPTP server setup, add IPtables firewall rules for UDP port 1723 and the GRE protocol:
sudo iptables -A INPUT -p tcp --dport 1723 -j ACCEPT
sudo iptables -A INPUT -p gre -j ACCEPT
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i ppp+ -o eth0 -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o ppp+ -j ACCEPTReplace eth0 with your network interface.
Step 7: Restart PPTP
Restart the pptpd service to apply all configuration changes:
sudo service pptpd restartYou have successfully installed and configured a PPTP VPN server on Linux!