Install PPTP VPN on CentOS 5 in 1 Minute
By rockia on Oct 03, 2010 with Comments 91
[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?
- 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. - 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. - 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.
Filed Under: Servers

It was great script.
Thank you.
Hi Hadi, just a special note that PPTP can only be installed on XEN servers.
Go Persian
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.
Excellent, makes setting up a VPN server a no brainer.
Yes, it makes the process extremely easy, too bad it’s works with CentOS on XEN platform only.
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!
What kind of errors are you getting? The script should set up the iptables automatically. If you can print your error here, maybe I can take a look of it.
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
Hi Mo ravan, I guess this has to be set up on your VPN client software.
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.
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.
Hi Mark, if this is the case, it’s easy, just create a file under /etc/ppp and copy the code to it. Then of course, you need to restart your PPTPd server.
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.
Well, it is working now but how to allow windows/samba sharing?
Thanks.
Alright this was an iptables issue.
Regarding sharing, the is done by adding proxyarp in the /etc/ppp/options.pptpd
Thanks.
Great script… Thanks
Worked well on my VPS with basic CentOS 5.5 install
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.
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 ?
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?
This script only works on CentOS on a XEN platform VPS.
how to add additional ip addres if i have more then one ips’s on the vps?
You can assign the external IP on pptpd server’s configure file, maybe I can write another post to explain it a little bit.
how to assign the external IP on pptpd server’s configure file?
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
i have installed using ur script but when trying to connect from client im getting error 800
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.
Thanks Rockia, that was easy!
lol, did you manage to install it within 1 minute as I said?
anyways, thanks for visiting, greg ! have fun with your VPN server.
how to create single sign on PPTP server?
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
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 ?
Hi shopboy, can you read my other post http://www.rockia.com/2010/10/how-to-setup-pptp-vpn-client-connection and see if you got everything right? Give it a try first and we might be able to narrow down the problems.
hi , i try to connect my vpn server but i get 619 error ? what can i do ?
I am getting the same error, what have you done to get it resolved?
Please email, email@vossjames.com
good shell program, it is very nice!
When want to connect to the server this message show:
The PPP link control protocol was terminated.
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!
Getting error 800 can u please tell me how to fix it
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.
Hi Edmund, you can follow this tutorial to set it up : http://www.rockia.com/2010/10/how-to-setup-pptp-vpn-client-connection . Cheers,
I got error 800. could you please tell me what’s wrong with me
?
Hi There,
I turned off it and I successfully connected my vpn.
I know It was stupid but the problem was my firewall
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.
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
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!
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
That’s true. If you type an IP address instead of “*” (* means any or don’t care) then only that user with that IP can connect.
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
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
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.
thanks for your good script.
my firewall block connection port.
what port use for this vpn?
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.
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.
Thank you Rockia. you rock!!
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.
thanx Rockia,god save you for us
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.
Right now the script won’t work on CentOS 6, but I will come up with a solution soon.
thank you! could u guide me to install pptp in centos 6?
hi im still downloading now.. hope it great!
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?
please post the tutorial for centos 6? thank you!
Excelente script mil gracias me funciona a la primera
estoy muy contento
mil gracias
Thanks very much for this, made it so easy!
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?
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.
Hi,
Thanks very much for this, it is working very fine.
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
Hi Rockia,
Was a perfect and 1 command togo toturial.
Thanx for your Script and Good Luck
Amir
Great… thanks bro!
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..
Thanks, I believe it’s a typo, it should be “nano /etc/ppp/chap-secrets”.
Good job writing Easy Installation of PPTP VPN Server on CentOS. I would like to read more about this topic.
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.
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!!!!
MAN UR GREAT THX YOU
GREAT! Please keep it up!
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.
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
good work ! very good work
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
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.
Thank you for good script. Please keep it up!
thanks! very helpful…
hi, thanks for your sharing
any limited for how many user can use this vpn server ?
and
any way to monitor vpn server status ?