Install PPTP VPN on CentOS 5 in 1 Minute

[Update]: If you are looking for automated script for CentOS 6, please visit “One Click Installation of pptpd VPN on CentOS 6” .

What is VPN?

A virtual private network (VPN) is a computer network that uses a public telecommunication infrastructure such as the Internet to provide remote offices or individual users with secure access to their organization’s network. It aims to avoid an expensive system of owned or leased lines that can be used by only one organization.

It encapsulates data transfers between two or more networked devices which are not on the same private network so as to keep the transferred data private from other devices on one or more intervening local or wide area networks. There are many different classifications, implementations, and uses for VPNs.

What can we do with VPN?

  1. To hide the users’ true IP address
    When using VPN connections, your client machine’s IP address will be hidden and your remote server (VPN server)’s IP address will be shown.
  2. Secure data transferred over the internet
    Most of the VPN will have the option to encrypt the data and thus they are safer to be transferred over the internet. This is especially good for company use.
  3. Access sites that are blocked in certain regions
    China is a very good example. Facebook, YouTube, Flickr and so many more websites are blocked in the country and people have to use different methods to bypass the restriction and VPN is one of the common way to achieve what they want.

How to set up PPTP VPN server on CentOS VPS?

Just in case some of the readers don’t know, I have moved my sites from shared hosting to Linode VPS a couple months ago. I was just thinking that my WordPress blogs don’t really need that much of resource anyways, why don’t I just set up a VPN server for my in-need use?

So for today, I will be introducing the easy installation of PPTP (Point-to-Point Tunneling Protocol) VPN on CentOS 5.5, if you want to know the server setup, you should probably ready my LNMP server setup guide first. Technically, you don’t even need a domain or a website, you can use your VPS purely for a VPN server.

Special Note: PPTPD can only be installed on XEN servers, for the difference of OpenVZ and XEN, you can visit http://www.rockia.com/2010/06/go-openvz-or-go-xen-for-vps

To get started, you need to use your root account to access your VPS server via SSH. Then type in the following command lines (pptpd.sh is not created by Rockia, I just host the file here for convenience, credits are back to Diahosting.com )

wget http://www.rockia.com/dl/pptpd.sh

Then hit “Enter”, the shell files should be downloaded on your server and now you can run it:

sh pptpd.sh

The installation will be run and completed automatically, and when it’s done, the VPN username and password will be displayed on your console screen.

Can I change the user name and password? Of course you can.

Change PPTP VPN account setting

The PPTP VPN server’s account information is stored in the file located at “etc/ppp/chap-secrets”, you can use the command line to edit this file directly:

nano /etc/ppp/chap-secrets

Or you can download the file, edit it and upload it back again, but anyways, you have to follow a simple syntax of the account setting:

Here is the screen-shot of my “chap-secrets” file. All you need to do is to type in the username you want to use (as vpn-user in the picture), then space and type in “pptpd”, and then space and the password (as vpn-password) in the picture and then “*” for the last one if you allow all IP address access your VPN server.

You will need restart PPTPD server when changes are made with the following command line:

/etc/init.d/pptpd restart

Post Note:

This is it. It’s extremely easy to install a PPTP VPN server on your VPS. However, if you are not comfortable with the “easy installation” package written by someone else, there are tons of tutorial online that you can read and try.

Happy VPNing.

add-vpn-connection

94 Comments

  1. It was great script.

    Thank you.

  2. Jon Davis Reply to Jon

    Thank you *very* much for making this script available.

    I’ve been trying to set up a PPTP VPN server for weeks and this worked on the first try.

  3. Excellent, makes setting up a VPN server a no brainer.

  4. I’m getting an error while installing on my XEN VPS. Its something to do with iptables. Do you think you can help? It would be great if you could. Thanks so much!

  5. Mo ravan Reply to Mo

    its amazing

    thanks for your great work.

    please let me know ,how can we change the encryption type 128bit to 40bit

    i really appreciate your help

    King Regards.
    Mo Ravan

  6. hey, thanks for the guide… but the problem im having… not all sites are opening… i tried opening some sites but its just stock there.

    • Hi Mark,I am not sure what OS you are using exactly, but if you are using Mac, you should check “Send all data via VPN” in “advanced” options. I believe there will be similar settings on other OS as well. Give it a try, otherwise, let me know the detail so I can try to narrow down the problem.

  7. after installing vpn on my centos server at fdcservers.net, i tried surfing the web some where working and some weren’t. so i am connect vpn from windows 7 pc to server centos… i checked to solved problem online but what i see is that i need to add this /sbin/ifconfig $1 mtu 1400 to /etc/ppp/ip-up. i cant even find /etc/ppp/ip-up its not showing up on my ssh. help

    thanks.

  8. Hello,

    First of all, let me thank you for making the script available.

    I could install everything on the xen vps successfully however when trying to connect from a windows machine, it goes through till verifying username and passwords and it gives error that connection cannot be established.

    Any ideas about that?

    Thanks in advance.

  9. Great script… Thanks
    Worked well on my VPS with basic CentOS 5.5 install

  10. Mo ravan Reply to Mo

    Hello,

    can you please guide me ,how can I limit bandwidth for an account from my CentOs VPN?

    or if there is any software to managed the VPN accounts

    Thanks.

  11. thanks for this script.

    However, after installation i didn’t find any ‘ppp’ folder under ‘etc’. I created it and created the chap-secrets file.

    when i tried to restart it says :

    /etc/init.d/pptpd restart No such file or directory

    what’s wrong ?

  12. dear Rockia

    i have installed it on my openvz vps and not working!
    but i have another dedicated server runnign centos 5.5.
    before try to install it there i want to know will it work there just fine?

  13. how to add additional ip addres if i have more then one ips’s on the vps?

  14. yo,

    ive installed you script and is working brilliantly except for 1 thing:

    After a while of working finely, it slows down and then completely stops. Its comes back up when I disconnect then connect again.? Is there a solution for this?

    This isnt a problem but I want to know how I connect my pptp server IP to a subdomain like for e.g. vpn.mysite.com, so for the server hostname (on client) I dont have to put the IP?

    Thank you

  15. i have installed using ur script but when trying to connect from client im getting error 800

  16. as long as your subdomain could be resolved to your VPN IP, I don’t see why you can’t use the subdomain as your VPN server hostname

    • Hey,

      Ive tried creating a subdomain and trying to forward it to the vpn ip but it doesnt work, ive even tried creating a host summary for it but that doesnt work either.

      I will try installing LAMP on the vpn server then try it again. That I believe should work.

      Anyways thank you.

  17. Thanks Rockia, that was easy!

  18. how to create single sign on PPTP server?

  19. hi
    thanks for this great script
    i want setup it to only 1 person can connect with 1 username
    now , in the same time some peapole can connect with one username

  20. Hi Rockia thanks for the great script.

    I can’t get my MAC to connect but not my PC. Any idea where the problem is ?

  21. hi , i try to connect my vpn server but i get 619 error ? what can i do ?

  22. soccer blog Reply to soccer

    good shell program, it is very nice!

  23. When want to connect to the server this message show:
    The PPP link control protocol was terminated.

  24. ITs GREAT! Reply to ITs

    Man, THANKS A LOT!

    I had a real headache with all this server vpn software stuff.
    Now it becomes really easy as 1-2-3!

  25. Getting error 800 can u please tell me how to fix it

  26. Edmund Tee Reply to Edmund

    Hi, great tutorial.
    Wanna ask, aftet setring up the vpn on centos, how can other pc (win7 or winxp) connect to the vpn on centos?

    Your help is much appreaciate .

    Thanks.

  27. I got error 800. could you please tell me what’s wrong with me :D ?

    • Hi There,
      I know It was stupid but the problem was my firewall :) I turned off it and I successfully connected my vpn.

      but I have different problem right now. When I connected vpn, I can not access anywhere. It looks like a DNS problem but I don’t know how can made it. I also can’t send ping or trace-route.

  28. hi
    every body
    it’s amazng way
    and it worked
    but thire is a problem
    when i connect i lose my internet connection and just ping to the server ip working
    and i don’t have ant internet
    but when i uncheck ( use defult gateway on remote network )
    my internet back but when i go to http://www.showip.com
    i found my real ip
    i need to have a full internet access from the centos server can you help me?
    and thx again

  29. Thanks for sharing your knowledge and skills. I tried your script after spending countless without success trying to get a vpn running with poptop. Your script ran first time without issue on my Centos Server. VPN worked first time

    Nice one !!!!!!! And thanks again you made the impossible, possible for me at least being a Linux babe!

  30. hi
    thanks for great tutorial.
    i have question if i want a user connect with static ip
    should i only type the static ip on etc/ppp/chap-secrets
    under ip addresses
    thank you

  31. If I will be using an internal networks with 192.168.100.1 – .255 and 192.168.101.1-.255 what can I change to be able to connect to the internall network?

    Than ks,
    JP

  32. hi
    i install the script in centos 5.5 , and every thing is OK
    when i try from my laptop to connect vpn
    tell me “VPN connection filled”
    (i follow this tutorial http://www.rockia.com/2010/10/how-to-setup-pptp-vpn-client-connection)
    info : i use ubuntu , control panel of server veportal

  33. i have a dedicated server centos 5.5,without any vps
    after install this script server was down.please help me fast.thanks

    • Do you mean the VPN server or the VPS? If the VPN is down you can use “/etc/init.d/pptpd restart” to restart the server. If it’s regarding to the VPS itself, please contact your VPS provider.

  34. thanks for your good script.
    my firewall block connection port.
    what port use for this vpn?

  35. Hello,

    I’m novice to this, I have installed the script and the process has gone successfully till end, could you please assist me how I can connect to this VPN using my local machine connected to internet?

    Thanks in advance.

  36. How can i have a user manager program with this?

    • Sorry, this script is currently on command line only. But hey, you know what? I think it’s a good idea to develop a GUI to manage the VPN users. I will get my hands on this project when I am less busy at my daily work. I know you might not come here very often, but I promise you, once I am done, I will email you a copy.

  37. Hello,

    Great script btw, I have setup and can connect with no problems, is there a way multiple accounts can be setup to connect?

    Thanks

    • Hello James, yes, you can edit the chap-secrets file and add multiple users (one per line, including name and password).

      I will probably make a GUI manager for it and send you once it’s done.

  38. thanx Rockia,god save you for us

  39. Could u help me install it in Centos 6, 32 bit? it did not create the chap secrets file or its directory. Some conflict with ppp version.

  40. Centos USER Reply to Centos

    hi im still downloading now.. hope it great!

  41. Thanks for this man, saved me so much work with openvpn, made a few modifications to the script to fit me exactly and I am well happy with it.

    One slight issue, (and im 100% its not a problem with your script). I tried to add echo “/sbin/ifconfig $1 mtu 1400″ >> /etc/ppp/ip-up

    When i checked that file afterwards it showed /sbin/ifconfig mtu 1400

    any chance you could help me there bud?

  42. please post the tutorial for centos 6? thank you!

  43. Thanks very much for this, made it so easy!

  44. The CentOS setup went smoothly. When I try to set up the VPN on my iPad 2, it asks for a “Secret” setting in addition to the user name and password. What is the “Secret” setting as established on the host computer?

  45. The secret problem is solved. I was using the L2PT tab instead of the PPTP tab. However, neither the iPad or my local Windows Vista systems will establish a connection to the CentOS server. Everything looks OK, pptd is running, the iptable contains the line
    “TCPMSS tcp — 172.16.36.0/24 anywhere tcp flags:FIN,SYN,RST,ACK/SYN TCPMSS set 1356″

    Any ideas? Thanks.

  46. Hi,

    Thanks very much for this, it is working very fine.

  47. hi;

    thank you very much for your script, every thing is working fine except that I could not surf any where !!
    I have traced by Microsoft tracert and I am 100% sure that packets are routed through my pptp connection through my VPS . but unfortunately surfing is impossible , I have 2 different VPS and I have this issue on both of them .

    Would you please Help me !

    Thank you
    Regards

  48. Hi Rockia,

    Was a perfect and 1 command togo toturial.
    Thanx for your Script and Good Luck :)

    Amir

  49. Great… thanks bro
    works great in mac for me (tested on centos 5.7) ..but i wonder if you can change this line ” nano etc/ppp/chap-secrets” to this “nano /etc/ppp/chap-secrets ”
    the first one, not work..

  50. joaca jocuri cu bile Reply to joaca

    Good job writing Easy Installation of PPTP VPN Server on CentOS. I would like to read more about this topic.

  51. I have installed PPTPd on Centos 5.6 and clients are connecting from windows XP. it was working fine , now from last 1 week My sessions are disconnecting after some time. I tried installing fresh pptpd but the issue is still there. Now i did capture PPP packets on client machines by Wireshark and got to know that when the disconnection occurs the PPP LCP protocol is showing Protocol reject messages where destination is the client IP. Any body encountered the same problem please share the solution.

  52. Great!!!! I have set up this with my Trixbox server – so I can call using mobile networks in the Netherlands – this is a country where all sip connections are blocked in the network.

    Thanks a lot!!!!

  53. on Centos 6 , i have this error, someone have a easy way alternative ???

    wget http://www.rockia.com/dl/pptpd.sh
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Loading mirror speeds from cached hostfile
    * base: centos.mirror.iweb.ca
    * extras: centos.mirror.iweb.ca
    * updates: centos.mirror.iweb.ca
    Setting up Install Process
    No package openvpnwget available.
    No package http://www.rockia.com/dl/pptpd.sh available.
    Error: Nothing to do
    [root@centos-box ~]#

    Tanks

    • First of all, this script won’t work with CentOS 6′s kernel.

      I think the result you posted as actually network issue. There might be network issue when you were trying to download the script from my site. If you run it again, it should download and installs. But like I said, it’s not for CentOS 6. I will post the CentOS 6 version once I tested it.

  54. GREAT STUFF.
    Thank you!

    Anyone succeeded in connecting to this VPN with a DD-WRT router? I think I “just” need the correct options.pptp file, so if anyone succeeded in connecting to this VPN from a CentOS or any other linux, perhaps you can share the commands and configuration files you have that’s working.

    I keep getting errors like:

    LCP terminated by peer (MPPE disabled)
    or
    Modem hangup
    or
    MPPE required, but MS-CHAP[v2] auth not performed.
    or others.

    Thanks a lot,
    Would very much appreciate your help.

    Amit

  55. Installed pptpd as above procedure.. able to connect vpn server.. but unable to browse internet.. so please help me from where i can change gateway IP?
    also is it possible if i can allow to open few url only.. and block other.. what about opening ports like 5060 and 5061

  56. It took me a long time to find a simple and working solution to enlable VPN on my VPS.

    I tried many times, without any visible effect.

    It took me just few minutes ;) and works perfectly.

  57. Thank you for good script. Please keep it up!

  58. hi, thanks for your sharing

    any limited for how many user can use this vpn server ?

    and
    any way to monitor vpn server status ?

  59. Hi,

    This script has always worked for me so far but today for a new VPS server I received the following error:

    error: Failed dependencies:
    libpcap.so.0.9.4 is needed by ppp-2.4.4-9.0.rhel5.i386
    warning: pptpd-1.3.4-1.rhel5.1.i386.rpm: Header V3 DSA/SHA1 Signature, key ID 862acc42: NOKEY
    error: Failed dependencies:
    ppp = 2.4.4 is needed by pptpd-1.3.4-1.rhel5.1.i386
    mknod: `/dev/ppp’: File exists
    pptpd.sh: line 25: /etc/ppp/options.pptpd: No such file or directory
    pptpd.sh: line 26: /etc/ppp/options.pptpd: No such file or directory
    pptpd.sh: line 33: /etc/ppp/chap-secrets: No such file or directory
    iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
    error reading information on service pptpd: No such file or directory
    pptpd: unrecognized service

    Any ideas what’s happening there to prevent that final step?

Leave a Reply