Installing and Configuring PPTP VPN on RHEL/CentOS 5


In the following tutorial, I will explain how to set up a PPTP VPN server on RHEL/CentOS 5, so that you can use it to browse the internet. So, if you have a RHEL/CentOS 5 dedicated server in US, you will be able to access US only sites.

A set up like this also has other benefits. Since the connection between the server and your computer will be encrypted, your ISP wont be able to intercept or track your internet usage.

Installation and Configuration

Ok, so lets get started. First make sure that you have ppp installed.

yum install ppp

In my case it was already installed, so I got the message ‘Package ppp – 2.4.4-1.el5.x86_64 is already installed’.

After you make sure that you have ppp installed, download and install Poptop. You can get the RHEL/CentOS 5 RPMs from http://poptop.sourceforge.net/yum/stable/rhel5/. I was using 64 bit version of CentOS 5. So I downloaded and installed the 64 bit (x86_64) version of the RPM.

wget http://poptop.sourceforge.net/yum/stable/rhel5/x86_64/pptpd-1.3.4-1.rhel5.1.x86_64.rpm

rpm -ivh pptpd-1.3.4-1.rhel5.1.x86_64.rpm

After installing Poptop, open the file /etc/pptpd.conf.

nano /etc/pptpd.conf

Go to the end of the file where you can see examples of localip and remoteip. Below them add your own values for localip and remoteip.

localip 10.0.0.1
remoteip 10.0.0.10-100

In the above, 10.0.0.1 will be used for the ppp interface and 10.0.0.10 – 10.0.0.100 will be assigned to the clients. You can also use different private IPs in ‘localip’ and ‘remoteip’, like 10.20.26.1 and 10.20.26.10-100. The OpenVPN documentation has some good info about numbering private subnets. Click here to check it out.

Next, open the file /etc/ppp/options.pptpd.

nano /etc/ppp/options.pptpd

Uncomment the ms-dns lines (by removing the ‘#’ in front of them) and change them to the dns servers provided by your ISP or to public DNS servers like ones provided by OpenDNS.

ms-dns 208.67.222.222
ms-dns 208.67.220.220

Thats all you need to change in the options.pptpd file. Next you will need to edit the file /etc/ppp/chap-secrets to add usernames and passwords for your clients. You need to enter the usernames and passwords in the following format.

# Secrets for authentication using CHAP
# client server secret IP addresses
username pptpd password *
username2 pptpd password2 *

You can also put a * in place of ‘pptpd’ just like there is a * below ‘IP addresses’. Also instead of a * below ‘IP addresses’ you can put the IP address from which the client will be connecting.

IP Forwarding and Firewall Rules

Now we need to enable IP forwarding. So open the file /etc/sysctl.conf and set ‘net.ipv4.ip_forward’ to 1.

net.ipv4.ip_forward = 1

To make the changes to sysctl.conf take effect, use the following command.

sysctl -p

Or you can also use the following command to enable IP forwarding temporarily.

echo 1 > /proc/sys/net/ipv4/ip_forward

Next, configure iptables to do NAT.

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

Next, we need to allow TCP port 1723 and the GRE protocol through iptables.

iptables -A INPUT -i eth0 -p tcp --dport 1723 -j ACCEPT
iptables -A INPUT -i eth0 -p gre -j ACCEPT

The following iptables rules are necessary if you want to be able to route all your internet traffic through the VPN server.

iptables -A FORWARD -i ppp+ -o eth0 -j ACCEPT
iptables -A FORWARD -i eth0 -o ppp+ -j ACCEPT

Now start the PPTP server if you haven’t already.

service pptpd start

If you followed the above steps correctly, the PPTP server should now be ready for use.

Troubleshooting

In case you are unable to connect to the VPN, check out the following Microsoft knowledge base article. It has some good troubleshooting tips.

http://support.microsoft.com/kb/314076/en-us

If you are unable to browse certain sites through the VPN, you may need to change the MTU of the ppp interface. To do this open the /etc/ppp/ip-up file and just before the last line, add the following line.

/sbin/ifconfig $1 mtu 1400

Save the file after that and then restart the PPTP server.

service pptpd restart

In my case the ppp interface was being assigned 1396 as the MTU. Due to which I was unable to browse some sites. After changing MTU to 1400, the problem went away.

Notes

I initially used PPTP since the site Relakks.com uses the same. But due to poor performance I have now switched to OpenVPN instead. If you are not satisfied with PPTP you should try OpenVPN. You will find excellent documentation on their website.

Anyway, I hope you have found the above tutorial useful. :)

Next Post:
Previous Post:

46 Comments

  1. ElAlecs

    Hi, I’ve got a Red Hat Enterprise Linux Server release 5.1 over a i386, I do all you say but when I try to connect to my server I’ve got a 619 error in a windows xp, Do you know what can be wrong?

  2. Anindya

    Hi, check out the following microsoft knowledge base article. http://support.microsoft.com/kb/227747/

    It might have solution to your problem. :)

  3. ElAlecs

    Thank you, all is working, the problem was is my ISP no my server, excelent article!

  4. firehawk895

    You Rock anindya!

  5. Ugur

    Hi Anindya,

    Great tutorial; but I cannot connect to my VPN. I enter my server’s IP address as my host name, but it doesn’t connect. I don’t even see the authentication. I think it has something to do with open ports or so but I did everything according to your tutorial. Thanks in advance

  6. Anindya

    @ugur,

    If you are using a firewall on the client computer, make sure that it is configured to allow PPTP.

    Also make sure that “PPTP passthrough” is enabled in your router. Check the following screen shot to see what I mean. http://img156.imageshack.us/img156/818/1282009112514ampq2.png.

  7. Azhar

    Hi, i have vista home and have a vpn connection in centos, now sometimes the connection works perfect but sometimes it just dont get connected.. i have to restart the server pc and then it work and then sometime later start playing up. please tell me what can i be doing wrong…

  8. Anindya

    @Azhar,

    I have no idea why that happens. It used to happen to me too. I experienced some other problems too with PPTP which is why I have switched to OpenVPN.

    If you are experiencing problems with PPTP, try OpenVPN.

  9. Tadej

    I did exactly as you wrote.. but I can`t connect from Vista to CentOS :(
    Can anybody add me to MSN, maybe?

  10. Anindya

    @Tadej

    If you are using a router, make sure that it supports PPTP passthrough and that it is enabled.

  11. mike

    When i try to install the pptpGUI i get issues with libglade.so and libxml.so and cannot process php4. Any ideas? it is driving me mad!!!

  12. Andy

    Great Tutorial !

    Would be great if you can publish just like this tutorial one but for OpenVPN.

  13. Anindya

    @mike,

    Sorry, I can’t help you. I am not familiar with pptpGUI and have no idea what relation it has with php 4. :(

  14. Anindya

    @Andy,

    Thanks!

    Maybe I will publish a tutorial for OpenVPN too. :)

  15. Ali

    I have Centos 5. I got this error:

    “This system lacks kernel support for PPP. This could be because
    the PPP kernel module could not be loaded, or because PPP was not
    included in the kernel configuration. If PPP was included as a
    module, try `/sbin/modprobe -v ppp’. If that fails, check that
    ppp.o exists in /lib/modules/`uname -r`/net.
    See README.linux file in the ppp distribution for more details.”

    Any suggestion?

  16. Anindya

    That error message is pretty straight forward.

    You are most likely using a virtual private server which is why your kernel doesn’t have PPP support. Also, on most virtual private servers, its not possible for the users to rebuild the kernel. If in your case, it is possible to rebuild the kernel, then follow the instructions found on this page to rebuild your kernel. You can enable PPP from the menu that appears after you use the “make menuconfig” command.

    Usually, you wont come across this problem in a dedicated server.

  17. Nev

    With PPP you can use the inbuilt client support within NT,XP,Vista etc, but with OpenVPN you have to install a client, or can OpenVPN support pptp connections also?

    Nev

  18. Anindya

    Yes, in case of OpenVPN you have to install the client. And no, OpenVPN doesn’t support PPTP.

  19. Shiv

    Anindya can i use mine VPS server as PPTP server, do i need router to setup PPTP VPN , is there any way in which VPN can be setup without router. Thanks and reply me asap.

  20. erick

    Hi,

    I already connected to linux vpn server from windows vpn client but can’t browsing internet,let me know what cause this ??

    thanks,

  21. Viking

    Hi

    i try to run this step :

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

    but i got error how can i remove this problem ?

    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    iptables: Unknown error 4294967295

  22. Anindya

    @Viking,

    Are you using a VPS?

    If yes, then most likely the iptables module ‘iptable_nat’ is not available. Usually virtual private servers have lot of stuff disabled, so that they don’t use too much system resources. I suggest that you contact your VPS provider for help with this problem.

  23. Viking

    sir

    do you have any yahoo or skype for live chat? if yes please email me

  24. Viking

    also i have error 619 when i try connect to vpn via my user and password on windows

  25. Anindya

    @Viking

    You still haven’t mentioned whether you are using a virtual private server or not. If you are using a virtual private server, then its very likely that you wont be able to solve the iptables problem yourself. You will have to contact your service provider.

    As for the ‘error 619′ problem, please check out this microsoft kb http://support.microsoft.com/kb/227747/.

    Also, I recommend that you use OpenVPN instead of PPTP.

  26. Viking

    i have VPS with Centos 5 as operation system , about PPTP , i want to use IBSng for accounting also my windows clients can access to my vpn without problem and with simple windows connection

  27. jacko

    @Anindya: i have disabled the iptables on my vps completely as i don’t want to be bothered with this port thingy. but still, i can’t connect to via vpn and it says error 619. could it be because the admin closed the vpn port?

  28. Anindya

    @jacko

    You need to have iptables enabled. It is iptables that handles the forwarding and NAT. Without those iptables rules you wont be able to route your internet traffic through the VPN. But you should still be able to connect to it.

    If you are unable to connect to the vpn and getting error 619, check out the microsoft kb article that I have linked to in one of my comments.

  29. vpn-user

    hiii civorel,,
    nice blog entries , i have tired this vpn server & am able to connect to the server but not able to access the internet . maybe its a routing issue.or fw related. what should be the local , the remote ip in my case .. server config & client are HERE http://pastebin.ca/1642753
    am using dedicated server rhel.

    Thank youu Anindya

  30. Anindya

    Since you are using a dedicated server, you can follow this tutorial step by step. You can use same local and remote ip as the one I have used in this tutorial or you can use other private subnets.

    I see that you have a public ip address in your ifcfg-eth1 file and not the ifcfg-eth0 file. If you are using eth1 as the public interface, you should replace eth0 in the iptables rules mentioned in this post with eth1.

    Example: iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

  31. vpn-user

    it wassss the apf firewall fault , not mine ;o thank you Anindya for you quick assistance.
    pptpd & internet are up and running but am getting the half connection speed when using pptp.
    any suggestions ;|

  32. Anindya

    Switch to OpenVPN. Thats what I did. :D

  33. Asif

    Dear All,
    i am using Red Hat Enterprise Linux Server release 5.4 and PPTPD release installed pptpd-1.3.0-0 but when i am try to register on PPTPD i am getting below mention error,

    same PPTPD is working on another system but it is not working on this system.

    Please let me know why i am getting this error. in configuration i have tried all above mention options.

    (Oct 30 12:02:18 server16 pptpd[695]: CTRL: Client 58.65.164.10 control connection started
    Oct 30 12:02:18 server16 pptpd[695]: CTRL: Starting call (launching pppd, opening GRE)
    Oct 30 12:02:18 server16 pppd[696]: Plugin /usr/lib/pptpd/pptpd-logwtmp.so is for pppd version 2.4.3, this is 2.4.4
    Oct 30 12:02:18 server16 pptpd[695]: GRE: read(fd=6,buffer=804fa20,len=8196) from PTY failed: status = -1 error = Input/output error, usually caused by unexpected termination of pppd, check option syntax and pppd logs
    Oct 30 12:02:18 server16 pptpd[695]: CTRL: PTY read or GRE write failed (pty,gre)=(6,7)
    Oct 30 12:02:18 server16 pptpd[695]: CTRL: Client 58.65.164.10 control connection finished)

    Regards,
    Asif

  34. Anindya

    Try removing pptpd and installing the latest version, that is version 1.3.4.

    Here are download links for both 32 bit and 64 bit rpms.

    http://poptop.sourceforge.net/yum/stable/rhel5/x86_64/pptpd-1.3.4-1.rhel5.1.x86_64.rpm
    http://poptop.sourceforge.net/yum/stable/rhel5/i386/pptpd-1.3.4-1.rhel5.1.i386.rpm

  35. Kismet

    Any idea on how to configure APF to allow pptpd to run?

  36. Anindya

    APF just controls iptables, so the iptables rules listed on this page should work fine for you. Also, you can put the iptables rules in the /etc/apf/postroute.rules file and APF will execute them automatically when it starts.

  37. Justin

    Hi Anindya

    It was a great guide you posted on configuring a vpn server, But I am having few issues. 1 is it takes sometime to connect, 2nd is if i am able to connect i am able to browse for like 5 minutes, and then i loose connectivity. Any ideas as to what might be causing this?

    Thanks :)

  38. Fen

    I also get the 619 error when trying to connect using Win XP. I installed the Poptop on VPS server (CentOS 5) using this guide. It seems that there are always issues on VPS servers.

    Then I installed poptop on normal CentOS (not using CentOS) and I didn’t have any problems. It works like a charm.

    Thanks, it is great tutorial.
    I

  39. Fen

    I meant when I’m not using VPS it works great. My bad :)

  40. Anindya

    @Justin

    Sorry, I have no idea what might be causing the issues you are having. :( You should try connecting to the VPN using a different computer and from a different network and if you see that you are still having the same issues, then the problem is most likely with the server. If not, then it could be a problem with your client computer or network.

    @Fen

    Virtual private server’s usually have many things disabled that are required for pptp, which is why others have had problems with VPSs too.

    Anyway, I am glad you found this tutorial useful. :)

  41. Jay

    I have created a VPN without problems and I can connect, but I cannot browse the web on my Windows machine. I checked and for some reason the VPN does not allocate a Gateway… could that be the issue?

    On my iPhone I can browse through the VPN with no problem.

  42. Manny

    Tnx! been looking for solution to my vpn problem till I found your site, whew! its been 2 weeks. Tnx much!

  43. faryad

    thank you! worked for me :)

  44. lin

    [root@abc ~]# service pptpd restart
    Shutting down pptpd: [失敗]
    Starting pptpd: /etc/host.conf: line 1: bad command `127.0.0.1   localhost.localdomain localhost’
    [失敗]
    Warning: a pptpd restart does not terminate existing
    connections, so new connections may be assigned the same IP
    address and cause unexpected results. Use restart-kill to
    destroy existing connections during a restart.
    求救

  45. bisteck

    When I run the iptables commands to allow the port and do NAT I don’t get any errors, but changes never take effect. Any ideas?

  46. Anindya

    @lin and @bisteck

    You guys should try googling if you haven’t already. ;)

Leave a Comment