在openwrt路由中加入n2n,并在ubuntu里加入n2n服务,实现开机联网互通互访

在openwrt路由中加入n2n,,并在ubuntu里加入n2n服务,实现开机联网互通互访1、openwrt的硬件环境:

将自己的WR703N刷入openwrt(这里需要修改FLASH芯片,换个8M的FLASH);刷机后,安装openwrt,此教程网上一大堆,无需说明了,TELNET进入,并开启SSH后,root登陆。

2、安装n2n到openwrt中:root@LeeKwen:~# opkg update<—–如果不能升级,请运行下条命令,查看源是否正确:root@LeeKwen:~# cat /etc/opkg.confroot@LeeKwen:~# opkg install n2n运行上述命令即可安装n2n。3、修改n2n的配置文件:root@LeeKwen:~# cat /etc/config/n2nconfig edgeoption 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服务的启动脚本:root@LeeKwen:~# vi /etc/init.d/n2n#!/bin/sh /etc/rc.common# Copyright (C) 2008-2012 OpenWrt.orgSTART=90start_instance() {local cfg="$1"config_get type "$cfg" TYPEcase "$type" inedge)config_get ipaddr "$cfg" 'ipaddr'[ -n "$ipaddr" ] || return 1config_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 1service_start /usr/sbin/supernode -l $port;;esac}stop_instance() {local cfg="$1"config_get type "$cfg" TYPEcase "$type" inedge)service_stop /usr/sbin/edge;;supernode)service_stop /usr/sbin/supernode;;esac}start() {config_load 'n2n'config_foreach start_instance 'edge'config_foreach start_instance 'supernode'}stop() {config_load 'n2n'config_foreach stop_instance 'edge'config_foreach stop_instance 'supernode'}5、将n2n加入openwrt系统启动项:root@LeeKwen:~# /etc/init.d/n2n enable 6、启动openwrt中的n2n服务:root@LeeKwen:~# /etc/init.d/n2n start root@LeeKwen:~# ifconfig edge0edge0Link encap:Ethernet HWaddr 86:CC:1B:E9:1A:DCinet addr:10.10.100.191 Bcast:10.10.100.255 Mask:255.255.255.0UP BROADCAST RUNNING MULTICAST MTU:1300 Metric:1RX packets:1117 errors:0 dropped:22 overruns:0 frame:0TX packets:698 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:500RX bytes:104415 (101.9 KiB) TX bytes:98732 (96.4 KiB)7、互通测试:与我的手机端 n2n互ping下root@LeeKwen:~# ping 10.10.100.103PING 10.10.100.103 (10.10.100.103): 56 data bytes64 bytes from 10.10.100.103: seq=0 ttl=64 time=31.738 ms64 bytes from 10.10.100.103: seq=1 ttl=64 time=25.347 ms64 bytes from 10.10.100.103: seq=2 ttl=64 time=22.565 ms64 bytes from 10.10.100.103: seq=3 ttl=64 time=40.063 ms64 bytes from 10.10.100.103: seq=4 ttl=64 time=23.577 ms^C— 10.10.100.103 ping statistics —6 packets transmitted, 5 packets received, 16% packet lossround-trip min/avg/max = 22.565/19.838/31.738 ms在ubuntu系统中增加n2n服务:1、我已经在上篇博客中有写如何在ubuntu安装n2n

(未安装过的用户请移驾)这里只说明增加n2n开机服务,具体步骤如下:

Leekwen@Leekwen:~$ svn co https://svn.ntop.org/svn/ntop/trunk/n2nLeekwen@Leekwen:~$ cd n2n/Leekwen@Leekwen:~/n2n$ lsn2n_v1 n2n_v2Leekwen@Leekwen:~/n2n$ cd n2n_v1/Leekwen@Leekwen:~/n2n/n2n_v1$ lsCOPYING edge.8 HACKING lzoconf.h Makefile minilzo.h n2n.hopenwrt scriptssupernode.ctuntap_linux.c twofish.c win32debian edge.c INSTALL lzodefs.h minilzo.c n2n.cn2n.spec README supernode.1 tuntap_freebsd.c tuntap_osx.c twofish.hLeekwen@Leekwen:~/n2n/n2n_v1$ makeLeekwen@Leekwen:~/n2n/n2n_v1$ ./edge -hWelcome to n2n v.1.3.2 for i686Built on 04/23/15 06:11:56 PMCopyright 2007-08 – edge -d <tun device> -a <tun IP address> -c <community> -k <encrypt key> -s <netmask> [-u <uid> -g <gid>][-f][-m <MAC address>]-l <supernode host:port> [-p <local port>] [-M <mtu>] [-t] [-r] [-v] [-b] [-h]-d <tun device>| tun device name-a <tun IP address>| n2n IP address-c <community>| n2n community name-k <encrypt key>| Encryption key (ASCII) – also N2N_KEY=<encrypt key>-s <netmask>| Edge interface netmask in dotted decimal notation (255.255.255.0)-l <supernode host:port> | Supernode IP:port-b| Periodically resolve supernode IP| (when supernodes are running on dynamic IPs)-p <local port>| Local port used for connecting to supernode-u <UID>| User ID (numeric) to use when privileges are dropped-g <GID>| Group ID (numeric) to use when privileges are dropped-f| Fork and run as a daemon. Use syslog.-m <MAC address>| Choose a MAC address for the TAP interface| eg. -m 01:02:03:04:05:06-M <mtu>| Specify n2n MTU (default 1400)-t| Use http tunneling (experimental)-r| Enable packet forwarding through n2n community-v| VerboseEnvironment variables: N2N_KEY| Encryption key (ASCII)Leekwen@Leekwen:~/n2n/n2n_v1$ pwd/home/Leekwen/n2n/n2n_v1别为坎坷阻力而叹息,用乐观心态面对人生遭遇,

在openwrt路由中加入n2n,并在ubuntu里加入n2n服务,实现开机联网互通互访

相关文章:

你感兴趣的文章:

标签云: