N2N v2 搭建过程
一、对N2N简单介绍
1. 概念
N2N是一个第二层点对点 代理 程序,它可以让用户在网络层而不是应用层使用一些点对点服务。
通俗说,连接后,可以全网段、全端口穿透。2. 原理
采用 UDP打洞原理
如果打洞失败,Supernode 会进行网络转发
对打洞端口,转发端口进行代理3. N2N 中 Supernode 和 Edgenode
Supernode 服务器安装使用,作用:打洞、转发
Edgenode 客户端安装使用
在两边edge的NAT情况比较好的情况下,会建立两个edge之间的直接连接、不需要依赖服务器,网速会很快;
当网络条件比较恶劣的时候,数据会从supernode中转,速度就靠到supernode的速度决定。4. 版本选择
N2N分 v1 和 v2 两个版本
通过查询资料,v2更稳定,并且openwrt 对 N2N v2支持更好
二、N2N v2 中 Supernode 搭建过程
环境: centos 7
官方地址: https://github.com/meyerd/n2n
安装前准备
yum -y install cmake gcc gcc-c++ git wget openssl-devel
进行安装
git clone https://github.com/meyerd/n2n.git cd n2n cd n2n_v2 cmake CMakeLists.txt make make install
开始启动
supernode -l 1000 -v -f
或者后台运行
supernode -l 1000 -v >/dev/null &
参数说明
-l <lport> Set UDP main listen port to <lport> // UDP 监听端口 -f Run in foreground. //前台运行 -u <UID> User ID (numeric) to use when privileges are dropped. // 指定运行所用的UID -g <GID> Group ID (numeric) to use when privileges are dropped. // 指定运行所用的GID -v Increase verbosity. Can be used multiple times. // 输出比较详细的log
三、配置客户端 Edgenode
未完待续
参考资料
[1]: https://github.com/meyerd/n2n
[2]: https://blog.youkuaiyun.com/qq_19393857/article/details/89352703 UDP打洞原理与N2N内网穿透
[3]: https://blog.slogra.com/post-716.html centos 7安装n2n v2
[4]: https://gofinall.com/78.html 内网穿透之n2n-介绍及使用说明
[5]: https://www.cnblogs.com/mousean/p/6007036.html n2n搭建手记-2-V2