N2N 对等VPN网络
n2n是一个二层的虚拟专网,允许用户开发网络中典型的P2P应用而不是在应用层开发。这就意味着用户可以透明的得到本地地址,只要新的IP地址在一个子网内,无论两台机器处于什么位置都能够ping通对方。
N2N网络的主要特点:
- n2n网络是基于P2P协议的二层加密网络
- 加密是在节点上完成的,而且使用的是用户的自定义密钥;你控制自己的安全,而不用让比如skype代表你(管理你的服务器节点)
- 每个n2n用户可以同时属于多个网络
- 能够反向的穿越NAT和防火墙,因此n2n节点即使在内网也是能够被访问到的,因此防火墙不再是IP级别直接通讯的障碍。
- n2n网络并没有设计成独立的(自包含的),但是可能能够在n2n和非n2n网络之间路由数据。
n2n构架是基于两个部分的:
终端节点:安装在用户计算机上的应用使n2n网络被创建。每个节点设备都会创建一个TUN/TAP虚拟网卡设备作为接入n2n网络的入口点。
超级节点:作用是使终端节点能够访问到对称防火墙后面的其他终端节点。这个程序是那些无法直接通讯节点的目录记录器和包路由器。

从图上可以看出,SuperNode作用是进行转发等通讯,因为其在公网,可以将两个内网的Edge节点连接起来。
- #!/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}
- ;;
- 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/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'
- }
从对应的启动文件可以看出,使用非常的简单。
- config edge
- option ipaddr ''
- option supernode ''
- option port ''
- option community ''
- option key ''
- option route ''
下面的内容是我的两台主机和服务器之间的通讯输出Debug信息
- 10/Sep/2013 23:51:47 [ n2n.c: 49] Marshalling hdr: public_ip=(2)0.0.0.0:0, private_ip=(2)0.0.0.0:7654
- 10/Sep/2013 23:51:47 [ n2n.c: 638] 84 bytes compressed into 87
- 10/Sep/2013 23:51:47 [ n2n.c: 681] ### Tx N2N Msg -> network
- 10/Sep/2013 23:52:17 [ n2n.c: 843] Purging old registrations
- 10/Sep/2013 23:52:17 [ n2n.c: 848] Remove 0 registrations
- 10/Sep/2013 23:52:22 [ n2n.c: 49] Unmarshalled hdr: public_ip=(2)0.0.0.0:0, private_ip=(2)0.0.0.0:50000
- 10/Sep/2013 23:52:22 [ n2n.c: 540] +++ Received unreliable data packet [rcvd_from=60.215.250.204:50000][msg_type=MSG_TYPE_REGISTER][seq_id=0]
- 10/Sep/2013 23:52:22 [ n2n.c: 545] [src_mac=DE:AD:BE:EF:01:23][dst_mac=00:00:00:00:00:00][original_sender=0.0.0.0:0]
- 10/Sep/2013 23:52:22 [supernode.c: 312] Received message from node [60.215.250.204:-15536]
- 10/Sep/2013 23:52:22 [ n2n.c: 49] Unmarshalled hdr: public_ip=(2)60.215.250.204:50000, private_ip=(2)0.0.0.0:50000
- 10/Sep/2013 23:52:22 [ n2n.c: 49] Marshalling hdr: public_ip=(2)0.0.0.0:0, private_ip=(2)0.0.0.0:7654
- 10/Sep/2013 23:52:22 [ n2n.c: 49] Unmarshalled hdr: public_ip=(2)0.0.0.0:0, private_ip=(2)0.0.0.0:7654
- 10/Sep/2013 23:52:22 [ n2n.c: 736] Sent unreliable packet [msg_type=MSG_TYPE_REGISTER_ACK][seq_id=0][src_mac=00:00:00:00:00:00][dst_mac=DE:AD:BE:EF:01:23]
- 10/Sep/2013 23:52:22 [ n2n.c: 49] Marshalling hdr: public_ip=(2)0.0.0.0:0, private_ip=(2)0.0.0.0:7654
- 10/Sep/2013 23:52:22 [ n2n.c: 638] 84 bytes compressed into 87
- 10/Sep/2013 23:52:22 [ n2n.c: 681] ### Tx N2N Msg -> network
- 10/Sep/2013 23:52:47 [ n2n.c: 49] Unmarshalled hdr: public_ip=(2)0.0.0.0:0, private_ip=(2)0.0.0.0:50001
- 10/Sep/2013 23:52:47 [ n2n.c: 540] +++ Received unreliable data packet [rcvd_from=60.215.250.204:50001][msg_type=MSG_TYPE_REGISTER][seq_id=0]
- 10/Sep/2013 23:52:47 [ n2n.c: 545] [src_mac=DE:AD:BE:EF:01:24][dst_mac=00:00:00:00:00:00][original_sender=0.0.0.0:0]
- 10/Sep/2013 23:52:47 [supernode.c: 312] Received message from node [60.215.250.204:-15535]
- 10/Sep/2013 23:52:47 [ n2n.c: 49] Unmarshalled hdr: public_ip=(2)60.215.250.204:50001, private_ip=(2)0.0.0.0:50001
- 10/Sep/2013 23:52:47 [ n2n.c: 49] Marshalling hdr: public_ip=(2)0.0.0.0:0, private_ip=(2)0.0.0.0:7654
- 10/Sep/2013 23:52:47 [ n2n.c: 49] Unmarshalled hdr: public_ip=(2)0.0.0.0:0, private_ip=(2)0.0.0.0:7654
- 10/Sep/2013 23:52:47 [ n2n.c: 736] Sent unreliable packet [msg_type=MSG_TYPE_REGISTER_ACK][seq_id=0][src_mac=00:00:00:00:00:00][dst_mac=DE:AD:BE:EF:01:24]
- 10/Sep/2013 23:52:47 [ n2n.c: 49] Marshalling hdr: public_ip=(2)0.0.0.0:0, private_ip=(2)0.0.0.0:7654
- 10/Sep/2013 23:52:47 [ n2n.c: 638] 84 bytes compressed into 87
- 10/Sep/2013 23:52:47 [ n2n.c: 681] ### Tx N2N Msg -> network
N2N 对等VPN网络的更多相关文章
- Azure Virtual NetWoker(一)对等互连网络
一,引言 Virtual NetWork Peering 可以无缝连接两个 Azure Virtual NetWork,Virtual NetWork Peering 直接的网络流量是专用的.在实际项 ...
- 用DotRas来连接VPN网络
最近要用程序来不断的连接VPN(为什么要这样就不讨论了),开始用的是如下代码: public static bool ADSL() { bool flag = true; do { Console.W ...
- [网络技术]VPN设置
1.解决VPN服务器默认路由困扰 现在移动办公已经变得家常便饭,每次外出出差办公需要访问单位的内网服务器时,该怎么办呢?相信很多人都想到了VPN连接!的确,使用VPN连接, 我们可以利用现成的Inte ...
- VPN拨号后使用本地网络上网
网络环境大概是这样了:我在家里用ADSL上网,通过VPN连接到公司的服务器.但是连接VPN后,只能登录到公司的服务器,与INTERNET就断开了,QQ.网页都断开了.公司的服务器应该是连网的,可能被限 ...
- VPN的分类方式
VPN的分类方式 VPN的分类方式比较混乱.不同的生产厂家在销售它们的VPN产品时使用了不同的分类方式,它们主要是产品的角度来划分的.不同的ISP在开展VPN业务时也推出了不同的分类方式,他们主 ...
- 001.网络TCP/IP工程知识点
一 互联网概述 计算机网络定义:由自主计算机互连起来的集合体. 计算机网络两大部分:硬件:计算机.通信设备.接口设备和传输介质. 软件:通信协议和应用软件. 广域网拓扑结构通常有:网状拓扑结构和环形拓 ...
- 数据中心网络架构的问题与演进 — 云网融合与 SD-WAN
目录 文章目录 目录 前文列表 云网融合 云网融合的应用场景 SD-WAN SD-WAN 的应用场景 企业组网互联 SD-EN 数据中心互联 SD-DCI 云间互联 SD-CX 企业用户接入云 数据中 ...
- Azure Site to Site VPN 配置手册
目录 1 Azure Site to Site VPN配置前的准备 1 1.1 设备兼容 1 1.2 网络要求和注意事项 1 2 配置Azure site t ...
- Neutron 理解(10):虚拟专用网(VPN)虚拟化 [How Neutron implements VPN Virtualization]
学习 Neutron 系列文章: (1)Neutron 所实现的虚拟化网络 (2)Neutron OpenvSwitch + VLAN 虚拟网络 (3)Neutron OpenvSwitch + GR ...
随机推荐
- C#删除数组元素代码
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...
- 初尝 MVC4
文章内容参考 http://www.cnblogs.com/leoo2sk/archive/2008/10/27/1320285.html 开发环境 VS2010 ,VS2010 开发 MVC4 需下 ...
- Java中报错No enclosing instance of type caiquan is accessible. Must qualify the allocation with an enclosing instance of type caiquan (e.g. x.new A() where x is an instance of caiquan).
package test;import java.util.Scanner;import java.util.Random;public class caiquan { public static v ...
- 校省选赛第一场A题Cinema题解
今天是学校省选的第一场比赛,0战绩收工,死死啃着A题来做,偏偏一直WA在TES1. 赛后,才发现,原来要freopen("input.txt","r",stdi ...
- win7下装ubuntu
需要的东西有: 1,ubuntu系统镜像,下载地址:http://www.ubuntu.com/download/desktop 选64位吧,兼容性好些. 2,空闲的大于20G硬盘空间,这个大小根据个 ...
- 【FJOI2014】【偏导+数学】病毒防护带
转载:http://trinklee.blog.163.com/blog/static/23815806020150155296528/ 问题描述: 众所周知,在国王胖哥的带领下,K国国泰民安,空前繁 ...
- 原生js判断是否有某个class,如果有就删掉,没有加上
<style> #div1 { width: 100px; height: 100px; position: absolute; } .div1 { background: red; } ...
- Android艺术开发探索第四章——View的工作原理(上)
这章就比较好玩了,主要介绍一下View的工作原理,还有自定义View的实现方法,在Android中,View是一个很重要的角色,简单来说,View是Android中视觉的呈现,在界面上Android提 ...
- Go语言探险思考笔记
最近接触对象存储,国际上鼎鼎有名的Amazon S3还有Google Cloud Service在国内由于防火墙还有机房过远的问题,并不能投入生产使用.国内有名的对象存储,大家众所周知的七牛云,后台就 ...
- CentOS+Apache+php无法访问redis的解决方法
PHP 使用 Redis 安装 开始在 PHP 中使用 Redis 前, 我们需要确保已经安装了 redis 服务及 PHP redis 驱动,且你的机器上能正常使用 PHP. 接下来让我们安装 PH ...