About Me

My photo
I know the last digit of PI

Thursday, December 05, 2013

Establishing VPN connection under Linux

Installation

You need to install the package
sudo apt-get install pptp-linux

Configuration

Create new VPN connection:
sudo pptpsetup --create <tunnel> --server <my-vpn-server-ip> --username <vpn-user-name> --encrypt
Create routing for the connection - you need to create a new file in the directory /etc/ppp/ip-up.d/ that contains the route. The content of the file should looks similar to:
#!/bin/bash

# This script is called with the following arguments:
# Arg Name
# $1 Interface name
# $2 The tty
# $3 The link speed
# $4 Local IP number
# $5 Peer IP number
# $6 Optional ``ipparam'' value foo

ip route add 10.42.0.0/16 dev $1
You can take a look of the parameters in /etc/ppp/ip-up script

Establishing connection

sudo pon <tunnel>

Disconnecting

sudo poff <tunnel>

Debugging issues

Start the connection in debug mode
sudo pon <tunnel> debug dump logfd 2 nodetach
Show pon/poff log:
sudo plog

Manually adding route

sudo ip route add 10.42.0.0/16 dev ppp0

Adding new user from shell

To add new use execute following commands:

Creates the new user

sudo adduser <username>

Add the user to existing group

sudo usermod -aG <groupname> <username>

Create new group

sudo addgroup <groupname>