Skip to content
certik edited this page Feb 8, 2011 · 16 revisions

How to Install n2n VPN

Ubuntu Client

Install n2n:

$ sudo apt-get install n2n

Create /etc/init/n2n.conf:

# n2n - Starts the n2n edge program that connects to the network
#
# This happens automatically when the network device is up.

description "connect using n2n"

start on net-device-up

exec edge -a 10.1.2.49 -c my_network_name -k my_password -l 134.197.117.197:1200

respawn

Change your IP address (-a), network name (-c), password (-k) and the server IP address and port (-l).

Start it using:

$ sudo initctl start n2n

The above n2n command has to be run as root, because it is creating a tun network device.

Mac Client

Install n2n:

$ git clone git://github.com/certik/n2n.git
$ cd n2n/n2n_v1
$ make

Install tuntap device from: http://tuntaposx.sourceforge.net/, follow the INSTALL file, and install things as root, install the startup scripts too.

And run it in screen:

$ screen
$ ./edge  -a 10.1.2.49 -c my_network_name -k my_password -l 134.197.117.197:1200

Test it. If it works, install it into StartupItems. Create /Library/StartupItems/n2n/StartupParameters.plist:

{
  Description     = "n2n";
  Provides        = ("n2n");
  Requires        = ("ethertap");
  OrderPreference = "None";
}

and /Library/StartupItems/n2n/n2n:

#!/bin/sh

##
# Run n2n
##

. /etc/rc.common

StartService ()
{
    ConsoleMessage "Initializing n2n"

    /Users/ondrej/repos/n2n/n2n_v1/edge -f -a 10.1.2.49 -c my_network_name -k my_password -l 134.197.117.197:1200
}

StopService ()
{
    ConsoleMessage "Stopping n2n"
    killall edge
}

RestartService ()
{
    ConsoleMessage "Restarting n2n"
}

RunService "$1"

Server

Install n2n:

$ apt-get install n2n

Run the super-node (as a regular user, not root):

$ supernode -l 1200

I usually run the above command in screen and detach it. To run it automatically after boot, do, create /etc/init/n2n-server.conf:

# n2n - Starts the n2n edge program that connects to the network
#
# This happens automatically when the network device is up.

description "connect using n2n"

start on net-device-up

exec supernode -l 1200

respawn

and start it using:

$ sudo initctl start n2n-server

IP Addresses

Please add your computer below if you use this net (and use some unused IP address). Add this to your /etc/hosts:

10.1.2.1 raven
10.1.2.2 tedg
10.1.2.3 spilka
10.1.2.4 tahoe
10.1.2.5 crow