Connect To a PPTP VPN from an Ubuntu Server using command line

I ended up in handling tens of linux servers remotely and as a developer running into sysadmin tasks is quite common. That's one of the reasons which make me become a command-line lover.
Anyway, in this situation the major issue for me is to make Google understand what am I really looking for, since this kind of problem is usually faced in a Desktop or GUI-based Ubuntu environment.

As I said it was really hard to let Google find something useful for my purpose, but after some heavy digging I could figure out how I should proceed
The Ubuntu version on which I perform this setup is a 12.04 LTS, so I can not guarantee for other versions. And in addiction to that often the information retrieved belongs to old Ubuntu releases.

In any case this is how I proceeded.

Note 1: you would use your favourite text editor (nano, pico, vim) where I may refer to VIM
Note 2: All the following commands are intended to be executed as superuser (using sudo or being root)
Note 3: the following term will be used thereinafter
  • $DOMAIN: the domain (NT domain) where the server is host
  • $USER: your remote user
  • $PASSWORD: your remote secret
  • $TUNNEL_ADDRESS: the remote server IP (of course meaning public IP)
1- First install the following packages
sudo aptitude install ppp pptp-linux

2- Then edit the following file /etc/ppp/chap-secrets
# Secrets for authentication using CHAP

# client         server    secret     IP addresses
Remember that Windows backslash "\" should be escaped

3- Now you are able to define your VPN connection by creating a file with a custom name (e.g my_vpn) in /etc/ppp/peers/. Here is what it should contain
:~$ cat  /etc/ppp/peers/my_vpn
pty "pptp $TUNNEL_ADDRESS --nolaunchpppd"
remotename PPTP
file /etc/ppp/options.pptp
ipparam my_vpn
Again remember to escape backslashes.

4- Now we are ready to establish our PPTP VPN tunnel with the following command
pon my_vpn &
I advise background mode but also for early check it si possible to start in a more verbose mode
pon my_vpn debug dump logfd 2 nodetach

5- As usually happens if everything goes fine you should now be able to see your machine in the VPN. In order to cross check try an ifconfig. Here is my output
ppp0      Link encap:Point-to-Point Protocol
          inet addr:  P-t-P:  Mask:
As you see now I have a new interface listed (ppp0), moreover this is assigned to a private IP, which looks fine for a VPN environment.

6- If you want to tear down the VPN here is the command.
poff my_vpn
That's it!

Che figata, keep on sharing knowledge!



  1. YOURVPN provides you the Cheap Vpn For Windows,Android, Iphone, Linux Pptp L2tp Sstp Ovpn $12 Per Year Only so just visit us Cheap Vpn For Windows Pptp L2tp Sstp Ovpn

  2. Tested on Ubuntu 14.04

  3. Anonymous24/8/15 22:17

    Thanks for solution.It works fine.

  4. Good solution for VPN connection on Ubuntu.
    Awesome post.Thank you.

  5. Hi. Very helpful thanks. Do you have any suggestions for the best way to monitor that the PPTP connection is up or down? I'm happy to cron a script and write to a log file. Thanks

    1. Well, I don't know much on that. Just a quick Google pointed me to two interesting links:

      Hope it helps...

  6. Replies
    1. Always happy when few lines can help someone :)


Post a Comment

Popular posts from this blog

Cloud Conf 2017

Scaling Host on Amazon AWS EC2 using Ansible