在openwrt路由中加入n2n,并在ubuntu里加入n2n服务,实现开机联网互通互访
1、openwrt的硬件环境:
将自己的WR703N刷入openwrt(这里需要修改FLASH芯片,换个8M的FLASH);
刷机后,安装openwrt,此教程网上一大堆,无需说明了,TELNET进入,并开启SSH后,root登陆。
2、安装n2n到openwrt中:
[email protected]:~# opkg update
[email protected]:~# cat /etc/opkg.conf
[email protected]:~# opkg install n2n
运行上述命令即可安装n2n。
3、修改n2n的配置文件:
[email protected]:~# cat /etc/config/n2n
config edge
option ipaddr '10.10.100.191'
option supernode '106.186.30.16'
option port '9876'
option community 'leekwen'
option key 'leekwen'
option route '1'
4、修改n2n服务的启动脚本:
[email protected]:~# vi /etc/init.d/n2n
#!/bin/sh /etc/rc.common
# Copyright (C) 2008-2012 OpenWrt.org
START=90
start_instance() {
local cfg="$1"
config_get type "$cfg" TYPE
case "$type" in
edge)
config_get ipaddr "$cfg" 'ipaddr'
[ -n "$ipaddr" ] || return 1
config_get supernode "$cfg" 'supernode'
config_get port "$cfg" 'port'
config_get community "$cfg" 'community'
config_get key "$cfg" 'key'
config_get_bool route "$cfg" 'route' '0'
[ "$route" = "1" ] && args='-r'
service_start /usr/sbin/edge -f $args -a $ipaddr -c $community -k $key -l ${supernode}:${port} -M 1300
;;
supernode)
config_get port "$cfg" port
[ -n "$port" ] || return 1
service_start /usr/sbin/supernode -l $port
;;
esac
}
stop_instance() {
local cfg="$1"
config_get type "$cfg" TYPE
case "$type" in
edge)
service_stop /usr/s