$ sudo apt-get install subversion build-essential libssl-dev
$ svn co https://svn.ntop.org/svn/ntop/trunk/n2n
$ cd n2n/n2n_v2
$ make
$ sudo make install

2.Supernode 节点调试

supernode -l [listening port] [-v] [-h]
#测试的时候,建议开启调试日志,比如:
supernode -l 8080 -v
3.添加节点

sudo edge -d edge0 -a 10.0.0.3 -c chun -u 1000 -g 1000 -k chunchu -l 111.111.111.111:8080 -m e8:5e:02:2a:21:32
4.添加系统启动自动运行

sudo vim /etc/rc.local
sudo edge -d edge0 -a 10.0.0.3 -c chun -u 1000 -g 1000 -k chunchu -l 111.111.111.111:8080 -m e8:5e:02:2a:21:32
Linux 下安装最为方便,按照上述的步骤的1、3、4即可。

OpenWrt 路由器的配置参照 连接。

Windows 下需下载 N2N 的GUI客户端,地址为 http://sourceforge.net/projects/n2nedgegui/。

Android 下 N2N 客户端下载地址为 https://play.google.com/store/apps/details?id=org.zhoubug.n2n_gui。

Mac OS 下的安装稍稍麻烦一点,需要安装 tun/tap 补丁,然后下载 N2N 源代码后需要打一下 补丁,在tuntap_osx.o文件里, 删除void tunclose(tuntapdev *device)这行,并将tunclose(device)替换为tuntapclose(device),改动这二处就可以了,然后编译安装。Mac 下会自动生成 tun 设备 tap0, 所以运行时不用指定-d 参数:

sudo edge -a 10.0.0.5 -c chun -k chunchu -u 1000 -g 1000 -m 5c:96:5d:8c:2c:4f -l 111.111.111.111:8080
参考资料:
1.http://www.shuyz.com/n2n-vpn-network-introduction-and-config.html
2.http://www.vpnhosting.cz/wiki/index.php/N2n_Gui_En
3.http://luca.ntop.org/n2n.pdf
4.http://ahui.us/post/p2pvpn_zhi_n2n_an_zhuang_shi_yong.html
5.http://linux.die.net/man/8/edge

参数-l是监听的端口,进程缺省是运行在后台的。可选参数:

supernode usage
-l Set UDP main listen port to
-f Run in foreground.
-v Increase verbosity. Can be used multiple times.
-h This help message.

  1. Ege的用法:

edge-a 10.10.0.1 -c mypbxn2n -k mypbxn2n -l 192.168.122.180:8888
edge -a 虚拟IP -c 你的虚拟网名 -k 密码 -l supernodeip:端口

edge -r -a 10.1.9.20 -c mypbxn2n -k mypbxn2n -l 209.141.56.138:4444

edge -c mynetwork -a 10.1.1.1 -k mypbxn2n -l 209.141.56.138:4444

edge -c mynetwork -a 10.1.1.2 -k mypbxn2n -l 209.141.56.138:4444

edge -d -a [static:|dhcp:] -c [-k | -K ] [-s ] [-u -g ][-f][-m ]
-l [-p ] [-M ] [-r] [-E] [-v] [-t ] [-b] [-h]

-d | tun device name
-a | Set interface address. For DHCP use ‘-r -a dhcp:0.0.0.0’
-c | n2n community name the edge belongs to.
-k | Encryption key (ASCII) - also N2N_KEY=. Not with -K.
-K | Specify a key schedule file to load. Not with -k.
-s | Edge interface netmask in dotted decimal notation (255.255.255.0).
-l | Supernode IP:port
-b | Periodically resolve supernode IP
: (when supernodes are running on dynamic IPs)
-p | Fixed local UDP port.
-u | User ID (numeric) to use when privileges are dropped.
-g | Group ID (numeric) to use when privileges are dropped.
-f | Do not fork and run as a daemon; rather run in foreground.
-m | Fix MAC address for the TAP interface (otherwise it may be random)
: eg. -m 01:02:03:04:05:06
-M | Specify n2n MTU of edge interface (default 1400).
-r | Enable packet forwarding through n2n community.
-E | Accept multicast MAC addresses (default=drop).
-v | Make more verbose. Repeat as required.
-t | Management UDP Port (for multiple edges on a machine).

Environment variables:
N2N_KEY | Encryption key (ASCII). Not with -K or -k.

Windows版

我没有在Win32下自己编译,http://www.vpnhosting.cz/n2nguien.exe提供了一个安装包,里面包含了V1和V2版本,注意使用时和自己所选版本的匹配。

单击advanced按键,勾选Enable packet forwarding through n2n community

注意在win7下,安装目录下的所有可执行文件,均需要以管理员身份运行。

apt-get install n2n