Avatar

Nino

ruby on rails engineer
Setup PPTP VPN server on CentOS 7
16 Nov 2014

This guide has been tested with CentOS 7 server.

Setup PPTP Server

First we need to install pptp server using yum

# yum install ppp pptp pptpd pptp-setup

Then we need to configure the pptpd

# vim /etc/pptpd.conf

Add server IP and client IP at the end of the file like below

localip 192.168.0.1
remoteip 192.168.0.100-200

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

# vim /etc/ppp/options.pptpd

Uncomment the ms-dns and change them to 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

# vim /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      *

Finally start your server

# service pptpd restart

To start PPTP Daemon automatically when rebooting next time, use the following command

# chkconfig pptpd on

Setup IP Forwarding

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

# vim /etc/sysctl.conf

Add the following line

net.ipv4.ip_forward=1

Then reload the configuration

# sysctl -p

Add forward rule to iptables

# vim /etc/rc.local
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

To ensure that /etc/rc.local script is executed during boot run the following

# chmod +x /etc/rc.d/rc.local

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.


comments