Monday, June 30, 2014

Install pptpd VPN server in centOS

To install PPTP in your centOS, first download the repo

rpm -i

Now install PPTPD

yum -y install pptpd

Now edit /etc/pptpd.conf and add the following lines:


Where localip is IP address of the server and remoteip are IPs that will be assigned to clients that connect to it.

Now, you should setup authentication for PPTP by adding users and passwords.
Simply add them to /etc/ppp/chap-secrets :

user1 pptpd "password" *

Add DNS servers to /etc/ppp/pptpd-options


service pptpd restart

Verify that it is running and accepting connections:

netstat -alpn | grep :1723

Now enable forwarding. Simply edit /etc/sysctl.conf and add the following line if it doesn’t exist there already:

net.ipv4.ip_forward = 1

To make changes active, run

sysctl -p

Now create a NAT rule for iptables

iptables -t nat -A POSTROUTING -o venet0 -j MASQUERADE

If you would also like your PPTP clients to talk to each other, add the following iptables rules:

iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
iptables -I INPUT -s -i ppp0 -j ACCEPT
iptables --append FORWARD --in-interface venet0 -j ACCEPT

Now save iptables