Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I would love to run all outgoing traffic (particularly torrent and web) through an PPTP VPN connection (to be specific a StrongVPN.com VPN). Everything needed to setup and more important to startup the VPN connection should be done over SSH, so everything needs to be command-line based.

My far set goal is to create a script to achieve an auto-connected always-on VPN script.

Just to be sure: It's not about setting up a PPTP-Server on the pi (there are plenty of tutorials for that) but to connect to a PPTP-Server.

share|improve this question
    
how to disconnect? I got the connection established but I don't get how to disconnect.. –  Jorrick Sleijster Apr 7 '13 at 11:40

1 Answer 1

up vote 10 down vote accepted

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.

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 in /etc/init.d containing these contents:

#! /bin/sh

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

exit 0

Then run:

update-rc.d [filename of script] defaults

To make it run at startup.

share|improve this answer
    
Awsome, you made my day. One followup question: Is there a way to check if connection has been connected inside a script? –  terman Aug 22 '12 at 18:12
    
@terman Hmm, I don't know, but from reading the docs I think not. However, I discovered a better way to run the VPN on boot, I'll link it right now. –  bearbin Aug 22 '12 at 18:15
    
awesome it worked for me. Do you know how to make this work with a split tunnel? So that only local requests are put out over the VPN and most of the web surfing is done of the regular connection. I tried removing defaultroute and replacedefaultroute but it didn't work. Do you have any ideas about it? –  Scoop Nov 26 '12 at 20:38
    
when I run this I get the error In file /etc/ppp/peers/provider: unrecognized option '/dev/modem' –  user3764 Dec 13 '12 at 14:42
1  
You'll need to chmod +x [filename of script] before running update-rc.d –  faulty Jan 9 '13 at 11:33

protected by Community Apr 7 '13 at 15:55

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.