Getting Started

* See also the Version 2 Getting Started Guide .

This page provides a quick-start tutorial to quickly get you running. We show how to setup the smallest n2n community (virtual network) using two edges and a supernode running on two hosts. Yes you really need two hosts, but most virtualisation environments should work, eg. VMWare or User Mode Linux.

We choose the community virtual network to be 10.1.2.0/24. This is the addresses reachable through n2n.

These instructions are UNIX-centric. If you run Windows, adapt the program names as appropriate.

What You Need

  • Two hosts. Yes you really need two (see above).
  • edge program.
  • supernode program.

Two hosts are needed otherwise OS internals will cause the IP packets to be routed internally without ever going via n2n. Virtualisation works fine though.

HostA

HostA will be the supernode and run an edge. The supernode will use UDP port 7654. Must be able to ping HostA from HostB.

HostA has external IP address 201.2.3.4. Substitute the real IP address for HostA here.

$ supernode -l 7654

as root

[user@HostA] $ sudo ./edge -d edge0 -a 10.1.2.1 -c testnet -k testkey -m 22:22:22:22:22:22 -l 201.2.3.4:7654

At this point the supernode and edge should both show that the new edge node is registered as a peer.

HostB

HostB will be an edge only and it has address 205.6.7.8. Substitute the real IP address for HostB here.

[user@HostB] $ sudo ./edge -d edge0 -a 10.1.2.2 -c testnet -k testkey -m 33:33:33:33:33:33 -l 201.2.3.4:7654

You should notice that supernode output now shows the second edge is registered.


Ping Test

Ping from HostB to HostA to see packets move over n2n.

[user@HostB] $ ping 10.1.2.1

or the following sends 1000 ping packets as fast as possible.

[user@HostB] $ ping -c 1000 -l 3 -f 10.1.2.1


How Did It Work

The edge0 interfaces created by n2n appear to the OS as ethernet ports. The network which is on that virtual ethernet is 10.1.2.0/24. All normal ethernet traffic like ARP packets and IP packets does in and out that interface just as if it was a real ethernet.

The difference is that n2n packs the ethernet packets into UDP and sends them across the internet.


What To Do Next

Next you should read the man pages for edge and start customising the command line to suite your own needs. You should look at

  • -u and -g to drop root privileges (for security)
  • -c <community name> to name your own community.
  • -k <shared key> to create your own encryption key. Also not the key can be passed in the environment so it does not need to be visible on the command line.

N2N and DHCP

It is possible to use n2n with DHCP. In this scenario DHCP is used to assign the IP addresses of the n2n edges which are usually assigned with the edge -a <address> option. This allows n2n edge clients to join a community and be assigned an IP upon joining. This is useful for LAN gaming and mobile office networks.

Recipe

  • Start client edge with -a 0.0.0.0 -r -m <mac> under unix
  • Start client edge with -a dhcp -r -m <mac> under Windows (patch pending)
  • Start DHCP server edge with a static IP as normal.
  • Run DHCP client on each client edge interface.

The -m <mac> option sets a static MAC address for the edge interface. If this is omitted then the DHCP server cannot assign a consistent IP address each time because edge will choose a random MAC.

N2N Version 2

In n2n version 2 use the following:

  • Start client edge with -a dhcp:0.0.0.0 -r -m <mac> (UNIX or Windows)