Sunday, May 27, 2007

VPN in Ubuntu

After my previous attempt at creating a VPN in Ubuntu I reverted all my work because I was rather unhappy with the results. After digging a bit more I found out I could actually use pptpconfig, as long as I didn't actually clicked the "Start" button. Here's the trick:

Start by installing pptpconfig. Add the following to your /etc/apt/sources.list file:

# James Cameron's PPTP GUI packaging
deb ./

Then install the app:

sudo apt-get update
sudo apt-get install pptpconfig

Now run it (sudo pptpconfig) and configure your VPN. In the "Routing" options, select "Client to LAN". Lets assume you called your new configuration MyVPN.

You can close pptpconfig. Go over to /etc/ppp/ip-up.d/ and create a new file called vpnroute (sudo gedit vpnroute). Assuming that the network you want to connect to uses IPs like 192.168.0.*, add this to the file:
if [ "${PPP_IPPARAM}" = "MyVPN" ]; then
route add -net netmask dev ppp0
Don't forget to make it executable, or it won't work:

chmod a+x vpnroute

And that's it. To start your VPN run:

sudo pon MyVPN

To stop it run:

sudo poff MyVPN
Post a Comment