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
2- Then edit the following file /etc/ppp/chap-secrets
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
4- Now we are ready to establish our PPTP VPN tunnel with the following command
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
6- If you want to tear down the VPN here is the command.
Che figata, keep on sharing knowledge!
References:
http://www.cyberciti.biz/tips/howto-configure-ubuntu-fedora-linux-pptp-client.html
http://pptpclient.sourceforge.net/howto-ubuntu.phtml
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)
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 $DOMAIN\\$USER PPTP $PASSWORD *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" name $DOMAIN\\$USER remotename PPTP require-mppe-128 file /etc/ppp/options.pptp ipparam my_vpnAgain 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:10.1.1.138 P-t-P:10.1.1.166 Mask:255.255.255.255As 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_vpnThat's it!
Che figata, keep on sharing knowledge!
References:
http://www.cyberciti.biz/tips/howto-configure-ubuntu-fedora-linux-pptp-client.html
http://pptpclient.sourceforge.net/howto-ubuntu.phtml
Tested on Ubuntu 14.04
ReplyDeleteThanks
Happy it worked
DeleteGreat connection......
ReplyDeletevpn connection
Good solution for VPN connection on Ubuntu.
ReplyDeleteAwesome post.Thank you.
10webhostingservice
happy that I could help
DeleteHi. 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
ReplyDeleteWell, I don't know much on that. Just a quick Google pointed me to two interesting links:
Deletehttps://github.com/boukeversteegh/pptpd-monitor
https://community.spiceworks.com/topic/130798-monitor-users-connected-to-pptpd-vpn
Hope it helps...
thanks :)
DeleteThanks
ReplyDeleteAlways happy when few lines can help someone :)
Delete