n2n 搭建虚拟局域网,实现内网穿透
一、ubuntu linux系统上通过源码安装
1、下载源码
git clone https://github.com/ntop/n2n
2、 进入源码目录n2n,依次执行下列命令
./autogen.sh
# 如果提示命令不存在,需要运行命令:apt-get update && apt-get install autoconf automake libtool 进行安装
./configure
make
make install
# 安装完执行命令,检查安装是否正确
supernode -h
edge -h
3、在公网主机上运行supernode,监听1234端口
supernode -l 1234 -v >/dev/null &
注:如果公网主机在云服务主机上,安全组需要放开1234端口,防火墙相应放开
firewall-cmd --zone=public --add-port=1234/tcp --permanent
#再重启一下防火墙
firewall-cmd --reload
4、测试
公网主机A也可以运行节点edge
edge -d n2n -c myn2n -k 123456 -a 10.0.0.1 -l x.x.x.x:1234 >/dev/null &
其中x.x.x.x为公网IP
另一台linux主机B运行节点edge
edge -d n2n -c myn2n -k 123456 -a 10.0.0.2 -l x.x.x.x:1234 >/dev/null &
两台主机可以互相ping通则搭建完成
二、windows版本下载安装
下载EasyN2N: https://download.csdn.net/download/JineD/90664182https://download.csdn.net/download/JineD/90664182
进行相关配置即可使用,注意的是如果有密码,需要 ”其它功能“ -> "常用功能” -> "附加参数" 中添加。
参考文章:
内网穿透与服务代理:N2N搭建与Nginx配置详解-CSDN博客
Linux arm 内核选项和busybox选项 加载tun模块 -- 创建/dev/tun 字符设备_linux .config tun-CSDN博客