PPTP Debian/Ubuntu OpenVZ Setup Script

What is PPTP?

PPTP is short for Point-to-Point Tunneling Protocol, a technology for creating Virtual Private Networks (VPNs) quickly. Support is built-in to many operating systems natively, without needing an additional client, unlike OpenVPN.

What does this script do?

This script will automatically PPTP/PoPToP on your OpenVZ VPS in a few of minutes. Port forwarding, server configuration, and authentication setup is all taken care of for you.

What if I want to do it myself?

A manual installation guide is available here for those of you who want to get down and dirty: http://www.putdispenserhere.com/pptp-vpn-setup-guide-for-a-debian-openvz-vps/

How do I install it?

1. Make sure that your VPS has its PPP module working. To check, run the following command:

cat /dev/ppp

If your VPS returns this message, then your PPP module is set correctly:

cat: /dev/ppp: No such device or address

If not, then you need to enable it in SolusVM (or disable and re-enable it).

2. Copy and paste these lines into your SSH client of choice:

wget https://raw.github.com/cwaffles/ezpptp/master/ezpptp.sh
chmod +x ezpptp.sh && ./ezpptp.sh

How can I contribute?

I’ve set up a Github repository here that you can fork and submit patches back to.

Script Source:

#!/bin/bash
# Interactive PoPToP install script for an OpenVZ VPS
# Tested on Debian 5, 6, and Ubuntu 11.04
# April 2, 2013 v1.11
# Author: Commander Waffles
# http://www.putdispenserhere.com/pptp-debian-ubuntu-openvz-setup-script/

echo "######################################################"
echo "Interactive PoPToP Install Script for an OpenVZ VPS"
echo
echo "Make sure to contact your provider and have them enable"
echo "IPtables and ppp modules prior to setting up PoPToP."
echo "PPP can also be enabled from SolusVM."
echo
echo "You need to set up the server before creating more users."
echo "A separate user is required per connection or machine."
echo "######################################################"
echo
echo
echo "######################################################"
echo "Select on option:"
echo "1) Set up new PoPToP server AND create one user"
echo "2) Create additional users"
echo "######################################################"
read x
if test $x -eq 1; then
	echo "Enter username that you want to create (eg. client1 or john):"
	read u
	echo "Specify password that you want the server to use:"
	read p

# get the VPS IP
ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`

echo
echo "######################################################"
echo "Downloading and Installing PoPToP"
echo "######################################################"
apt-get update
apt-get -y install pptpd

echo
echo "######################################################"
echo "Creating Server Config"
echo "######################################################"
cat > /etc/ppp/pptpd-options <<END
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
ms-dns 8.8.4.4
proxyarp
nodefaultroute
lock
nobsdcomp
END

# setting up pptpd.conf
echo "option /etc/ppp/pptpd-options" > /etc/pptpd.conf
echo "logwtmp" >> /etc/pptpd.conf
echo "localip $ip" >> /etc/pptpd.conf
echo "remoteip 10.1.0.1-100" >> /etc/pptpd.conf

# adding new user
echo "$u	*	$p	*" >> /etc/ppp/chap-secrets

echo
echo "######################################################"
echo "Forwarding IPv4 and Enabling it on boot"
echo "######################################################"
cat >> /etc/sysctl.conf <<END
net.ipv4.ip_forward=1
END
sysctl -p

echo
echo "######################################################"
echo "Updating IPtables Routing and Enabling it on boot"
echo "######################################################"
iptables -t nat -A POSTROUTING -j SNAT --to $ip
# saves iptables routing rules and enables them on-boot
iptables-save > /etc/iptables.conf

cat > /etc/network/if-pre-up.d/iptables <<END
#!/bin/sh
iptables-restore < /etc/iptables.conf
END

chmod +x /etc/network/if-pre-up.d/iptables
cat >> /etc/ppp/ip-up <<END
ifconfig ppp0 mtu 1400
END

echo
echo "######################################################"
echo "Restarting PoPToP"
echo "######################################################"
sleep 5
/etc/init.d/pptpd restart

echo
echo "######################################################"
echo "Server setup complete!"
echo "Connect to your VPS at $ip with these credentials:"
echo "Username:$u ##### Password: $p"
echo "######################################################"

# runs this if option 2 is selected
elif test $x -eq 2; then
	echo "Enter username that you want to create (eg. client1 or john):"
	read u
	echo "Specify password that you want the server to use:"
	read p

# get the VPS IP
ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`

# adding new user
echo "$u	*	$p	*" >> /etc/ppp/chap-secrets

echo
echo "######################################################"
echo "Addtional user added!"
echo "Connect to your VPS at $ip with these credentials:"
echo "Username:$u ##### Password: $p"
echo "######################################################"

else
echo "Invalid selection, quitting."
exit
fi

This script is built on Denis’s OpenVPN script modified for Debian support and PPTP installation. Source: http://bluemodule.com/software/openvpn-install-script-for-openvz-vps/

Bookmark the permalink.

66 Responses to PPTP Debian/Ubuntu OpenVZ Setup Script

  1. Anonymous says:

    Hi , thank you for this script . i installed it . now when i want to connect with vpn connection i get 734 error : The PPP link Control Protocol was terminated

    can you tell me what’s reason of it ? and how can i solve it ?

  2. Stephano says:

    This is working perfectly on my BuyVM 15$/year VPS!!! Thank you sooooo much!!!!

  3. christian says:

    Is it ok for XEN aswell?

    • Anonymous says:

      The IP detection won’t work right, change the line that says this: ifconfig venet0:0 | grep ‘inet addr’ | awk {‘print $2′} | sed s/.*://

      Change to this:
      grep address /etc/network/interfaces | grep -v 127.0.0.1 | awk ‘{print $2}’

      I’m not sure if the ppp modules will install though. Good luck.

  4. aquario says:

    Hi, thanks for your script.  I used it on my BuyVM machine., but when I tried to connect, the server kept reporting error 619, saying that the connection could not be established.  Any idea on this?

    Many thanks

  5. Lukas says:

    Hello there. Thanks for very nice PPTP VPN manual. I got just one question. IS it possible to monitor users traffic on VPN ? Give users quota for VPN ? Problem is on my server is users making too mutch traffic and i need to stop this. Thanks for any help. lu

    • Anonymous says:

      I do not know unfortunately. Perhaps you could check the logs. This script was designed for personal use though. Sorry if I cannot help much.

  6. Syamsul says:

    Thank you. This works perfectly for my RAMHost OpenVZ VPS, though I did first have to install iptables.

  7. Syamsul says:

    How would you suggest that iptables be setup to secure the VPS such that only the SSH, OpenVPN and PPTP ports are left open? An automated script for this would also be incredibly helpful. Thank you!

  8. Nick T says:

    Confirmed working on BuyVM.net / Frantech.ca

  9. Takola28 says:

    works great on vps i purchased from vpseu.com

  10. mehran khajavi says:

    if you have not openvz just replace venet0:0 with your interface
    it works fine

  11. Marl says:

    very useful script! just one question (or request) though, is it possible to have the user one active login only?

    • Anonymous says:

      I don’t think so. Perhaps it’s hidden in the documentation. You can also try to use iptables to limit the amount of connections to ppp device.

  12. Nathan says:

    Thanks so much for the script! One question; my iPhone cannot connect to my VPN that I run on my VPS. I’ve checked my logs, it says “modem hangup”. So I then moved to my modem’s config page.

    http://www.dd-wrt.com/wiki/index.php/Static_PPTP_VPN_Client#Configure_PPTP_Client <== documentation on proper config
    http://i43.tinypic.com/oqlu84.png <== current config

    So far my router could be the problem. But I see no more modem hangup in my error logs, as I did before I configured the router.
    Feb  2 05:01:54 server1 pppd[7927]: Plugin /usr/lib/pptpd/pptpd-logwtmp.so load$Feb  2 05:01:54 server1 pppd[7927]: pppd 2.4.5 started by root, uid 0Feb  2 05:01:54 server1 pppd[7927]: Using interface ppp0Feb  2 05:01:54 server1 pppd[7927]: Connect: ppp0 /dev/pts/1Feb  2 05:01:57 server1 pppd[7927]: Connection terminated.Feb  2 05:01:57 server1 pppd[7927]: Connect time 0.1 minutes.Feb  2 05:01:57 server1 pppd[7927]: Sent 0 bytes, received 0 bytes.Feb  2 05:01:57 server1 pppd[7927]: Exit.

    So what is wrong? How can I edit it to become iPhone friendly?

    Thanks again,
    Nathan

  13. KD says:

    Thanks. Finally got it working :)

  14. Cofin says:

    i got this message at all the vps i bought

    WARNING: Deprecated config file /etc/modprobe.conf, all config files belong into /etc/modprobe.d/.
    FATAL: Module ip_tables not found.
    iptables v1.4.10: can’t initialize iptables table `nat': Table does not exist (do you need to insmod?)
    Perhaps iptables or your kernel needs to be upgraded.

  15. Robiq says:

    I was intall your script but when i try to connect from my mac or iphone i cant and i got this error:
    “pppd[1434]: Couldn’t open the /dev/ppp device: No such file or directory”Can U help me with this please? I try to start VPN on VPS with ubuntu 11.04

  16. Pingback: Linux VPS PPTP Help

  17. Pure says:

    thought it was very hard to setup vpn on my vps, then i used ur script, took me like 1 minute to get everything going. thank man! no errors occurred.

    • Asri says:

      Oh my – Ditto to that!
      Been struggling to get VPN to work on my VPS, following the steps here works like a charm the first time in less than 5 minutes.

      Awesome!

  18. vuysun says:

    wow perfect! thanks this worked on my buyvpn

  19. Good reader says:

    Thank you so much! Works perfectly on micronetvps.com’s VPS’s (They have 6 locations! perfect for vpn)

  20. Worked nice with buyvm 128m VPS…

  21. Guest says:

    What if it says “cat: /dev/ppp: No such file or directory”. ?

  22. Pingback: How to install a pptpd VPN on Linux/Debian | tiq's tech-blog

  23. Omer Abbas says:

    I am unable to use VPN over mac, can you tell me settings? and what about the forwarding ips?

  24. Nico2706 says:

    Indeed, works perfect with Buyvm !
    To have an US IP, do this:
    touch /root/.usvpn
    iptables -L -t nat -n (view the existing rules)
    iptables -F -t nat (this is a complete flush, you can just remove or reorder the rules)
    ptables -t nat -A POSTROUTING -s 10.1.0.0/24 -j SNAT –to-source
    iptables -L -t nat -n

  25. Mastersey says:

    Hi, Thanks for this script ! Anyway, i still have a 800 error message when i try to connect to the VPN :(

  26. MO says:

    I have tried several times on different vps but never get connected, how do i find out what the error is? debug?

  27. zbenta says:

    I tried the script and got the folloging from the daemon.log after having chmod +x the /usr/sbin/pppd file:

    Client xxx.xxx.xxx.101 control connection started

    CTRL: Starting call (launching pppd, opening GRE)

    GRE: read(fd=6,buffer=6075a0,len=8196) from PTY failed: status = -1 error = Input/output error, usually caused by unexpected termination of pppd, check option syntax and pppd logs

    CTRL: PTY read or GRE write failed (pty,gre)=(6,7)

    CTRL: Reaping child PPP[2585]

    CTRL: Client xxx.xxx.xxx.101 control connection finished

    MGR: PPP binary /usr/sbin/pppd not executable

  28. Edmund Fisher says:

    Amazing, you rock! :D

  29. noahgray says:

    404, script file not found.

  30. May I just say that I’ve tried SO many things before, and only with this was I able to do it properly. Thanks a bunch!

  31. Jules D says:

    I have the 619 error :s with the script

    • CommanderWaffles says:

      Can you post a full description? Or the log?

      • Matt Davis says:

        Same problems here. “Connection to the remote computer could not be established, so the port used for this connection was closed”. Occasionally I get an 809 or an 800, but the error message is the same. Exploring Windows Logs reveal alternating “Connection could not be established” and “Remote machine actively refused connection”.

  32. Pingback: PPTP Debian/Ubuntu OpenVZ Setup Script | Tang Labs

  33. Francis M says:

    Thanks for the script. But it won’t let my Tomato router connect whatever I do until I replaced the following lines

    echo “option /etc/ppp/pptpd-options” > /etc/pptpd.conf

    to

    cp -R /etc/ppp/pptpd-options /etc/pptpd.conf

    then it connects brilliantly and distributes the tunnel to all devices connected.

  34. Thanks for automatic script…. Can I use it on XEN based VPS?

  35. Cool says:

    Is there a way to make this script use one of the ipv6 addresses on my VPS or use this on an IPv6 only vps?

  36. Andi says:

    I got 619 –> 691 connection refused, any idea?
    I’m using windows7 to connect my VPS with ppp enabled and pptp installed as described above

  37. Pingback: Anonymous

  38. Pingback: Linux PPTP VPN Server | adilmehmoodbutt

  39. Pingback: Easy PPTP VPN install for Debian/Ubuntu | Tech Riot

  40. Non techie says:

    Been trying to setup vpn the whole day. Was about to give up then I found this. Worked like a charm. Thanks cwaffles

  41. Thank you, this works everytime.

  42. Izwan Rahman says:

    Hi its working for my BuyVM openvz vps yay! working with my windows 7.

    but to connect directly using my DD-WRT? can someone please help me with dd-wrt pptp settings?

    Remote Subnet:

    Remote Subnet Mask:

    MPPE Encryption:

    MTU (Default: 1450):

    MRU (Default: 1450):

    NATEnable Disable

    please.. thanks in advance, really appreciate it.

  43. Gavin says:

    If anyone is having problems with Error 619, etc, make sure you have both TUN/TAP and PPP enabled on your VPS. Mine passed the “dev /cat/ppp” test, but still came up with the error.

  44. Pingback: PPTP Debian/Ubuntu OpenVZ Setup Script | lowendguide.com

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>