VPN PPTP Client on Raspberry Pi

To start, you will need to install pptpclient, this can be achieved by:

sudo apt-get install pptp-linux

Next, Create a file in /etc/ppp/peers with arbitrary name and the following contents:

pty "pptp $VPNHOSTNAME --nolaunchpppd --debug"
name $USERNAME
password $PASSWORD
remotename PPTP
require-mppe-128
require-mschap-v2
refuse-eap
refuse-pap
refuse-chap
refuse-mschap
noauth
debug
persist
maxfail 0
defaultroute
replacedefaultroute
usepeerdns

Where $VPNHOSTNAME is your VPN host name, $PASSWORD is your VPN password and $USERNAME is your VPN username.

After you have done that, you should do:

sudo pon $FILENAME

where $FILENAME is the name of the file you saved earlier. Or you should do this to see debug messages (this command will display logs until connection off):

pon $FILENAME debug dump logfd 2 nodetach

To start your VPN client on boot, you can follow the instructions on http://pptpclient.sourceforge.net/howto-debian.phtml (point 8 or 9, Hand configuration section)

An alternate method to make your VPN client run on boot is to make a script /etc/init.d/pptp containing these contents:

#! /bin/sh

case "$1" in
  start)
sleep 10
pon $/etc/ppp/peers/FILENAME

    echo "PPTP Started"
    ;;
  stop)
    poff $/etc/ppp/peers/FILENAME
    echo "PPTP Stopped"
    ;;
  *)
    echo "Usage: /etc/init.d/pptp {start|stop}"
    exit 1
    ;;
esac

exit 0

Then run:

update-rc.d [filename of script] defaults

To make it run at startup.

11 thoughts on “VPN PPTP Client on Raspberry Pi”

  1. How do I configure my PPTP client running on my RPi 3 to use the SAME STATIC IP ADDRESS each time my RPi3 logs in via PPTP? Example: I want my RPi 3 to be assigned 10.0.1.99 each time it connects to my VPN Server at work. Yes, my VPN Server allows a PPTP Client to use the same Static IP inside my office network.
    -Thanks

  2. You should configure your pptp server to assign same IP to the user every time the user logs on:
    On pptp server
    in /etc/ppp/chap-secrets
    username * password 10.1.2.3

  3. Hi, thank you for this step-by-step configuration!
    Can you please do the same but with L2TP VPN with start VPN L2TP on boot. Please name this article as VPN L2TP Client on Raspberry Pi. Thank you

  4. Hi,
    I tried to make the VPN client run on boot making the script /etc/init.d/pptp but it didnt’t work
    I read point 9 here http://pptpclient.sourceforge.net/howto-debian.phtml and since I’m using a ppp0 connection (sim on 4G module) and I have the default /etc/network/interfaces file, I tried:

    iface tunnel inet ppp
    provider myfile

    auto ppp0
    iface ppp0 inet dhcp
    post-up /sbin/ifup tunnel
    pre-down /sbin/ifdown tunnel

    but I didn’t work, what can I do?
    I’m using Raspbian Buster

    1. also how can I prevent VPN client to change my default route?
      I tried to remove defaultroute and replacedefaultroute but it didn’t work

  5. I would a put a metrics for every connection
    priority: first interface Wifi, second that PPP, third eth0

    auto wlan0
    allow-hotplug wlan0
    iface wlan0 inet dhcp
    metric 200

    auto ppp0
    iface ppp0 inet dhcp
    metric 300

    auto eth0
    allow-hotplug eth0
    iface eth0 inet dhcp
    metric 400

  6. I had to change the line in the config file: pty “pptp $VPNHOSTNAME –nolaunchpppd –debug”
    to pty “/usr/sbin/pptp $VPNHOSTNAME –nolaunchpppd –debug” to get it to run at startup – it could not find the pptp command without specifying the path.

  7. I have a Raspberry Pi4 and did everything as described. To get root rights I entered “sudo su”. With the command “ls” I displayed that the “vpn” file I had created was available. When the command is started: pon /etc/ppp/peers/vpn, the message appears: The file /etc/ppp/peers//etc/ppp/peers/vpn does not exist. Please create it or use a command line argument to use another file in the /etc/ppp/peers/directory. What am I doing wrong?

Leave a Reply

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