Setting up a PPTP server on Linux

2 min read
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 PPTP

Step 1: Install PPTP Packages

Open the terminal and install the required PPTP packages by entering the following commands:

sudo apt update
sudo apt install pptpd

Step 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-secrets

Inside 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.101

Step 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.conf

Add 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 clients

Step 4: Configure DNS

Configure DNS by editing the /etc/ppp/pptpd-options file. Add Google DNS:

nano /etc/ppp/pptpd-options

Add the following lines to the file:

ms-dns 8.8.8.8
ms-dns 8.8.4.4

Step 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.conf

Add 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=1

Save and close the file.

Then, apply the sysctl changes with this command:

sudo sysctl -p

Step 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 ACCEPT

Replace eth0 with your network interface.

Step 7: Restart PPTP

Restart the pptpd service to apply all configuration changes:

sudo service pptpd restart

You have successfully installed and configured a PPTP VPN server on Linux!

Didn’t find the answer?Contact support — we’ll help you sort it out.
Open a ticket →