搭建環境
supernode :阿里雲主機一台 aly1(Centos 6.5)
edg2node:美團雲機器兩台 mty1,mty2(Centos 7.0)
Step-1 各機器安裝subviersion 並編譯安裝n2n_v1
#很重要,確保gcc和ssl版本一致,
yum install subversion gcc-c++ openssl-devel
svn co https://svn.ntop.org/svn/ntop/trunk/n2n
cd n2n/n2n_v1/
make && make install
cp supernode /usr/sbin/
cp edge /usr/sbin/
Step-2 中心節點super aly1 開啟服務和端口
遠程登錄至aly1
vim /etc/sysconfig/iptables
*filter下配置
-A INPUT -p tcp -m tcp --dport 1000 -j ACCEPT
iptables save
#啟動supernode (注:此處開放端口在配置邊緣節點機器時用)
supernode -l 1000 -v >/dev/null &
Step-3配置邊緣節點機器
分別登錄兩台美團雲機器,設置邊緣節點(xxx.xxx.xxx.xxx:1000 即為阿里雲super機器ip)
邊緣節點1
edge -d n2n0 -c mynetwork -k encryptme -a 10.0.0.1 -l xxx.xxx.xxx.xxx:1000 >/dev/null &
邊緣節點2
edge -d n2n0 -c mynetwork -k encryptme -a 10.0.0.2 -l xxx.xxx.xxx.xxx:1000 >/dev/null &
Step-4 驗證n2n網絡通訊
在節點1 ping 10.0.0.2 ,在節點2 ping 10.0.0.1 網絡正常。
ssh 10.0.0.x可互聯。
n2n網絡搭建完成。
------------ -------------- --------------- ----------------- ------------------ -----------
n2n的命令詳解
1 edge -d <tun device> -a <tun IP address> -c <community> -k <encrypt key> -s <netmask> [-u <uid> -g <gid>][-f][-m <MAC address>] 2 -l <supernode host:port> [-p <local port>] [-M <mtu>] [-t] [-r] [-v] [-b] [-h] 3 4 -d <tun device> | tun device name 5 -a <tun IP address> | n2n IP address 6 -c <community> | n2n community name 7 -k <encrypt key> | Encryption key (ASCII) - also N2N_KEY=<encrypt key> 8 -s <netmask> | Edge interface netmask in dotted decimal notation (255.255.255.0) 9 -l <supernode host:port> | Supernode IP:port 10 -b | Periodically resolve supernode IP 11 | (when supernodes are running on dynamic IPs) 12 -p <local port> | Local port used for connecting to supernode 13 -u <UID> | User ID (numeric) to use when privileges are dropped 14 -g <GID> | Group ID (numeric) to use when privileges are dropped 15 -f | Fork and run as a daemon. Use syslog. 16 -m <MAC address> | Choose a MAC address for the TAP interface 17 | eg. -m 01:02:03:04:05:06 18 -M <mtu> | Specify n2n MTU (default 1400) 19 -t | Use http tunneling (experimental) 20 -r | Enable packet forwarding through n2n community 21 -v | Verbose