Join N2N in OpenWrt Routing and join n2n service in Ubuntu to enable networking and mutual exchange

Source: Internet
Author: User

Add n2n to OpenWrt routing, and add n2n service in Ubuntu to enable networking and mutual exchange of 1, OPENWRT hardware environment:

To brush their own wr703n into the openwrt (here need to modify the flash chip, change a 8M flash);
After the brush machine, install OPENWRT, this tutorial online a lot of, no need to explain, telnet into, and open ssh after the root landing.

2, install n2n to OpenWrt:[email protected]:~# opkg update <-----If you can't upgrade, run the next command to see if the source is correct:
[Email protected]:~# cat/etc/opkg.conf
[Email protected]:~# opkg Install n2n
Run the above command to install the N2N.

3, modify the n2n configuration file:

[Email protected]:~# cat/etc/config/n2nconfig 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. Modify the startup script of the N2N service:

[email protected]:~# vi/etc/init.d/n2n#!/bin/sh/etc/rc.common# Copyright (C) 2008-2012 openwrt.orgstart=                90start_instance () {local cfg= ' $ ' 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= "$"     Config_get type "$cfg" type Case "$type" in Edge) 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_instanc E ' Supernode '}

5. Add n2n to OpenWrt system startup:[email protected]:~#/etc/init.d/n2n Enable

6, start the OpenWrt in the N2N service:[email protected]:~#/etc/init.d/n2n start

[Email protected]:~# ifconfig edge0edge0     Link encap:ethernet  HWaddr 86:cc:1b:e9:1a:dc          inet addr : 10.10.100.191  bcast:10.10.100.255  mask:255.255.255.0 up          broadcast RUNNING multicast  mtu:1300  metric:1          RX packets:1117 errors:0 dropped:22 overruns:0 frame:0          TX packets:698 errors:0          dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:500          RX bytes:104415 (101.9 KiB)  TX bytes:98732 (96.4 KiB)

7, interoperability testing: With my mobile phone end n2n Mutual Ping

[Email protected]:~# ping 10.10.100.103PING 10.10.100.103 (10.10.100.103): 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 ti me=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

Adding N2N Services to Ubuntu systems:

1. I have written in the previous blog How to install n2n in Ubuntu

(for users who have not installed, please move http://blog.csdn.net/leekwen/article/details/45095887)
Here only to increase the N2N boot service, the specific steps are as follows:


[email protected]:~$ SVN co https://svn.ntop.org/svn/ntop/trunk/n2n[email protected]:~$ CD N2n/[email  protected]:~/n2n$ lsn2n_v1 n2n_v2[email protected]:~/n2n$ CD N2N_V1/[EMAIL&NBSP;PROTECTED]:~/N2N/N2N_V1 $ lscopying edge.8 HACKING lzoconf.h Makefile minilzo.h n2n.h openwrt scripts supernode.c Tuntap_li NUX.C twofish.c Win32debian edge.c INSTALL lzodefs.h minilzo.c n2n.c n2n.spec README supernode.1 tuntap_f REEBSD.C tuntap_osx.c twofish.h[email protected]:~/n2n/n2n_v1$ make[email protected]:~/n2n/n2n_v1$. Edge-hwelcome to n2n v.1.3.2 for i686built on 04/23/15 06:11:56 pmcopyright 2007-08-http://www.ntop.orgedge-d <tun Device>-a <tun IP address>-C <community>-K <encrypt key>-S <netmask> [u <uid>-G &lt ; 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 is running on dynamic IPs)-P <local port> | Local port used for connecting to Supernode-u <UID> | User ID (numeric) to use when privileges is Dropped-g <GID> | Group ID (numeric) to use when privileges is 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) [email protected]:~/n2n/n2n_v1$ PWD/HOME/LEEKWEN/N2N/N2N_V1


2. After downloading and compiling, write the start service file n2n:[email protected]:~/n2n/n2n_v1$ vi n2n

#!/bin/bash# #Some Variable define here # #PROG = "Edge" n2n_ip= "10.10.100.103" n2n_cname= "Leekwen" n2n_pass= "Leekwen" Snode_host= "106.186.30.16" snode_port= "9876" logs= "/var/log/$PROG. Log" prog_path= "/HOME/LEEKWEN/N2N/N2N_V1" # Edge Binary put on here for testing this script, not Needed if the system binary. prog_args= "-f-d edge0-a $n 2n_ip-c $n 2n_cname-k $n 2n_pass-l $SNODE _host: $SNODE _port-m 1300" pid_path= "/var/run" RETVAL =0start () {pid= ' ps ax | grep $PROG | grep-v "grep" | awk ' {print '} ' if [!-Z ' $pid]; then # # program        is running, exit with error. echo "error! $PROG is currently running! " 1>&2 exit 1 Else # # change from/dev/null to something like/var/log/$PROG if you want to save out        Put. $PROG _path/$PROG $PROG _args 2>&1 > $LOGS & Echo "$PROG started" echo $pid > "$PID _path/$PRO   G.pid "fi retval=$? If [$RETVAL-eq 0]; Then Echo-e "\\033[60g\c" echo-e "[\\033[1;32m\c" Echo-E "ok\c" echo-e "\\033[0;39m\c" echo "]" Else Echo-e "\\033[60g\c" ECHO-E "[\\033[1;31m\c]  Echo-e "failed\c" echo-e "\\033[0;39m\c" echo "]" fi return $RETVAL}stop () {pid= ' ps ax | grep $PROG | Grep-v "grep" | awk ' {print '} ' if [!-Z ' $pid ']; Then # # program was running, so stop Itkill $pid rm-f "$PID _path/$PROG. pid" echo "$PROG stop        Ped "Else # # program was not a running, exit with error. echo "error! $PROG not started! "   1>&2 Exit 1 fi retval=$? If [$RETVAL-eq 0]; Then Echo-e "\\033[60g\c" echo-e "[\\033[1;32m\c" Echo-e "ok\c" echo-e "\\033[0;39m\c" Echo       "]" Else Echo-e "\\033[60g\c" echo-e "[\\033[1;31m\c" Echo-e "failed\c" Echo-e "\\033[0;39m\c" echo "]" fi return $RETVAL}## Check to see if we is running as root first.## Found at http://www.cyberciti.biz /tips/shell-root-user-check-script.hTmlif ["$ (id-u)"! = "0"]; Then echo "This script must is run as root, you can use sudo command to run it."    1>&2 exit 1ficase "$" in start) Start exit 0;    Stop) stop exit 0;;    Reload|restart|force-reload) stop start exit 0;; * *) echo "Usage: $ start|stop|reload}" 1>&2 exit 1;; Esac

3, add executable permissions, mobile n2n service to/etc/init.d/, and update rc.d

[Email protected]:~/n2n/n2n_v1$ chmod 755 n2n[email protected]:~/n2n/n2n_v1$ sudo mv N2n/etc/init.d/[email protected]:~ /n2n/n2n_v1$ sudo update-rc.d n2n defaults


4. Test the N2N service:

[Email protected]:~/n2n/n2n_v1$/etc/init.d/n2n start[email protected]:~/n2n/n2n_v1$ ifconfig edge0[email protected]: ~/n2n/n2n_v1$/etc/init.d/n2n stop[email protected]:~/n2n/n2n_v1$ ifconfig edge0[email protected]:~/n2n/n2n_v1$/etc/ init.d/n2n restart[email protected]:~/n2n/n2n_v1$ ifconfig edge0


5. Ping connectivity test for N2N service:

[Email protected]:~/n2n/n2n_v1$ ping 10.10.100.103PING 10.10.100.103 (10.10.100.103): Data bytes64 bytes from 10.10.10 0.103:seq=0 ttl=64 time=11.738 ms64 bytes from 10.10.100.103:seq=1 ttl=64 time=15.347 ms64 bytes from 10.10.100.103:seq =2 ttl=64 time=12.565 ms64 bytes from 10.10.100.103:seq=3 ttl=64 time=10.063 ms64 bytes from 10.10.100.103:seq=4 ttl=64 time=13.577 ms^c---10.10.100.103 ping statistics---5 packets transmitted, 5 packets received, 0% packet Lossround-trip m In/avg/max = 10.063/12.838/15.347 ms

to this client has been successfully installed, in the case of network connectivity, each time you restart Ubuntu and OpenWrt routes, they will automatically connect to the Supernode node, to build a peer-to network.


Join N2N in OpenWrt Routing and join n2n service in Ubuntu to enable networking and mutual exchange

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.