TorGuard Account Area

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 124.123.123.123 is the IP of the PPTP server you want to connect to, and MYTGACCOUNTUSERNAME with your VPN username)

pty "pptp 123.123.123.123 --nolaunchpppd"
lock
noauth
nobsdcomp
nodeflate
name MYTGACCOUNTUSERNAME
remotename tgvpn
ipparam tgvpn
require-mppe-128
usepeerdns
defaultroute
persist


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
username[tab]tgvpn[tab]password[tab]*

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:

#!/bin/bash
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:

curl http://checkip.dyndns.org

Notes:

  • 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