Add to Favourites    Print this Article

How to Connect to PPTP from Command Line

This tutorial explains how to connect via PPTP protocol on Linux using command-line, so you don't need to use any network managers of GUIs like KDE, Gnome, etc.

Check if ppp-generic module exists. If not, it will probably not work:

modprobe ppp-generic

Install necessary packages:

apt-get install pptp-linux pptpd ppp curl

Create PPTP configuration file:

nano /etc/ppp/peers/tgvpn

Enter this as content of the "tgvpn" file:
(replace is the IP of the PPTP server you want to connect to, and MYTGACCOUNTUSERNAME with your VPN username)

pty "pptp --nolaunchpppd"
remotename tgvpn
ipparam tgvpn

Enter VPN login credentials into chap-secrets file:
([tab] being replaced by a tab, username with your VPN account username and password with your PPTP password):

nano /etc/ppp/chap-secrets

Create script to replace default routes - otherwise the VPN is not being used by your system:

nano /etc/ppp/ip-up.local

Enter this as content of the "ip-up.local" file:

H=`ps aux | grep 'pppd pty' | grep -v grep | awk '{print $14}'`
DG=`route -n | grep UG | awk '{print $2}'`
DEV=`route -n | grep UG | awk '{print $8}'`
route add -host $H gw $DG dev $DEV
route del default $DEV
route add default dev ppp0

Make this script executable:

chmod +x /etc/ppp/ip-up.local

To connect to the VPN:

pon tgvpn

To disconnect from the VPN:

poff tgvpn

Check your current IP:



  • You can check via "ifconfig" if there is a ppp0 adapter. If there is, you are successfully connected.
  • All commands must be run with "sudo" if you're not logged in as a root user.
  • When you are connected but the VPN is not being used by your system, incorrect iptables / routing rules are responsible.
    Try running "route add default dev ppp0"

Also Read