Setup PPTP VPN Server on Debian/Ubuntu Linux | Drupal 8

Setup PPTP VPN Server on Debian/Ubuntu Linux

Submitted by nuwantha on Sun, 04/29/2018 - 17:49
Question

How to setup a VPN server (PPTP) on Debian based linux (Debian / Ubuntu / Linux Mint ...) ?

Setup PPTP Server

First we need to install pptp server using apt-get

# sudo apt-get install pptpd

Then we need to configure the pptpd.

# sudo nano /etc/pptpd.conf

Add server IP and client IP at the end of the file. You can add like below: (Set the range as you want)

localip 192.168.0.1
remoteip 192.168.0.240-250

This sets up the PPTP server to use IP 192.168.0.1 while distributing the IP range 192.168.0.100 to 192.168.0.200 to PPTP clients. Change these as you wish as long as they are private IP addresses and do not conflict with IP addresses already used by your server.

Configure DNS servers to use when clients connect to this PPTP server

# sudo nano /etc/ppp/pptpd-options

Uncomment the ms-dns and add google like below or OpenDNS

ms-dns 8.8.8.8
ms-dns 8.8.4.4

Now add a VPN user in /etc/ppp/chap-secrets file.

# sudo nano /etc/ppp/chap-secrets

The column is username. Second column is server name, you can put “pptpd” in there. Third column is password. The last column is the IP addresses, you can put * to allow all IP.

# client server secret IP addresses username * myPassword *
myname    *    mypass    *

Finally start your server

# sudo /etc/init.d/pptpd restart
# OR
# sudo service pptpd restart

 

Setup IP Forwarding (Access Internet via VPN)

To enable IPv4 forward. Change /etc/sysctl.conf file, add forward rule below.

# sudo nano /etc/sysctl.conf

Uncomment the line

net.ipv4.ip_forward=1

Then reload the configuration

sudo sysctl -p

Firewall : Add forward rule in iptables

# sudo nano /etc/rc.local

adding to the bottom just before the exit 0
Note : Change the interface name (eth0) if necessary, Use inconfig to get interfaces

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

This example is using 192.168.0 for its PPTP subnet. The second rule adjusts the MTU size :

You are done. Just reboot your server and you should be able to connect to using PPTPD and send all your traffic through this server.

Start PPTPd Service on boot

You can use:
sudo systemctl enable pptpd.service
# OR
sudo update-rc.d pptpd default

 

NOTE : If you use Debian 9

Follow the tutorial "Add rc.local to Debian 9 Stretch" to create /etc/rc.local
or
follow this tutorial to add rules  : https://wiki.debian.org/iptables

 

Tags

Add new comment