使用N2N搭建虚拟局域网联机游戏(服务端)
客户端
本站已搭建免费公益N2N服务端,并制作了N2N的启动器,如需直接联机游戏,请移步:
服务端(Linux)
以下安装编译基于CentOS 7 64bit,版本为n2n 3.0.0,尽量使用同版本服务端和客户端,避免发生兼容性问题,导致无法连接
注:以下安装方式二选一
RPM安装
yum install libzstd -y
wget https://github.com/ntop/n2n/releases/download/3.0/n2n-3.0.0-1038.x86_64.rpm
rpm -i n2n-3.0.0-1038.x86_64.rpm
编译安装
编译环境
#CentOS
yum install autoconf automake libtool git kernel-headers -y
#Ubuntu
apt-get install autoconf make gcc -y
开始编译
wget https://github.com/ntop/n2n/archive/refs/tags/3.0.tar.gz
tar xzvf 3.0.tar.gz
cd n2n-3.0
./autogen.sh
./configure
make && make install
启动服务端
详细的服务端参数见这里 EasyN2N 服务端(Supernode)附加参数
#实际使用时,可以去掉 -f 参数,使其后台运行
supernode -p 9527 -f
若服务器开启了如iptables\firewalld\ufw等防火墙,需要放行supernode所设置的端口,否则客户端无法连接
#firewalld
firewall-cmd --zone=public --add-port=9527/udp --permanent
firewall-cmd --reload
#iptables
iptables -I INPUT -p udp --dport 9527 -j ACCEPT
service iptables save
service iptables restart
#ufw
ufw allow 9527/udp
另外,如果使用的阿里云、腾讯云等云服务器,还需要单独再在安全组中放行使用的端口(UDP)
服务端(Windows)
下载 EasyN2N,界面菜单中打开服务端
选择服务端的版本(默认v3,推荐v3),一键启动
详细的服务端参数见这里 EasyN2N 服务端(Supernode)附加参数
和Linux端类似,开启了Windows防火墙的机器需要注意放行指定的端口,或关闭防火墙
另外,如果使用的阿里云、腾讯云等云服务器,还需要单独再在安全组中放行使用的端口(UDP)
265 条评论
Hi
我想询问一下N2N对于单网卡多IP的情况的支持
比如我edge边缘节点 用内网IP 连接到 supernode 但是这台edge和 supernode都是具有公网IP的
那么其他的边缘节点可以通过edge的公网IP P2P 连接到这台edge吗
作者大大,easyn2n能不能支持ipv6建服务器呢,没有ipv4公网IP,想和朋友直连
@唐子峻
N2N不支持IPv6,但是可以P2P的,试试先~
https://bugxia.com/2292.html
小黄鸭得 -k 参数怎么用? -k是给服务器加密码吗 如果加了密码 其他人怎么输入密码?
[2022-10-08 21:26:22] shutting down…
[2022-10-08 21:26:22] ok, I am leaving now
[2022-10-08 21:26:25] adding supernode = 43.143.155.49:1919
[2022-10-08 21:26:25] starting n2n edge 3.1.1-16-g23e168b-dirty-r1200 x64_static May 8 2022 23:45:52
[2022-10-08 21:26:25] using compression: none.
[2022-10-08 21:26:25] using null cipher.
[2022-10-08 21:26:25] number of supernodes in the list: 1
[2022-10-08 21:26:25] supernode 0 => 43.143.155.49:1919
[2022-10-08 21:26:25] WARNING: encryption is disabled in edge
[2022-10-08 21:26:25] successfully created resolver thread
[2022-10-08 21:26:25] successfully created port mapping thread
[2022-10-08 21:26:25] automatically assign IP address by supernode
[2022-10-08 21:26:25] send REGISTER_SUPER to supernode [43.143.155.49:1919] asking for IP address
[2022-10-08 21:26:28] send REGISTER_SUPER to supernode [43.143.155.49:1919] asking for IP address
[2022-10-08 21:26:31] send REGISTER_SUPER to supernode [43.143.155.49:1919] asking for IP address
[2022-10-08 21:26:34] send REGISTER_SUPER to supernode [43.143.155.49:1919] asking for IP address
[2022-10-08 21:26:37] send REGISTER_SUPER to supernode [43.143.155.49:1919] asking for IP address
请问一下大佬出现这种情况怎么解决,
你好!如何设置supernode参数,只允许自己的edge连接
Bug侠大佬您好,我跟着步骤完成了,并启动了supernode,n2n填入自定义服务器,服务器地址+端口后, 点n2n的【启动】 但是不分配地址,请问要怎么做
@marco
无法自动分配IP的问题我也不太清楚,可以试着自定义虚拟IP吧
你好大佬 按照教程执行了
编译安装
yum install autoconf automake libtool git kernel-headers -y
wget https://github.com/ntop/n2n/archive/refs/tags/3.0.tar.gz
tar xzvf 3.0.tar.gz
cd n2n-3.0
./autogen.sh
./configure
make && make install
这条命令显示执行成功
——————————–
然后开启服务器
06/Sep/2022 20:54:13 [supernode.c:588] WARNING: using default federation name; FOR TESTING ONLY, usage of a custom federation name (-F) is highly recommended!
06/Sep/2022 20:54:13 [sn_utils.c:136] calculated shared secrets for edge authentication
06/Sep/2022 20:54:13 [supernode.c:604] supernode is listening on UDP 7654 (main)
06/Sep/2022 20:54:13 [supernode.c:613] supernode opened TCP 7654 (aux)
06/Sep/2022 20:54:13 [supernode.c:620] supernode is listening on TCP 7654 (aux)
06/Sep/2022 20:54:13 [supernode.c:629] supernode is listening on UDP 5645 (management)
06/Sep/2022 20:54:13 [supernode.c:641] dropping privileges to uid=99, gid=99
06/Sep/2022 20:54:13 [sn_utils.c:807] successfully created resolver thread
06/Sep/2022 20:54:13 [supernode.c:659] supernode started
之后呢怎么操作?
是在客户端服务器那栏输入我的公网ip地址:7654就行了嘛? 为什么在客户端输入这一串之后 点击启动 没有给我分配虚拟IP? 希望大佬能抽出时间解答一下 我也学习一下 谢谢
@小张
1.对,看日志,supernode已经运行正常了
2.如果客户端运行不正常,需要分析日志,是不是客户端没连上supernode?
@Bug侠
感谢作者回复,我查询了一下日志,显示如下:
[2022-09-07 15:55:49] shutting down…
[2022-09-07 15:55:55] adding supernode = 118.31.12.101:7654
[2022-09-07 15:55:55] starting n2n edge 3.1.1-16-g23e168b-dirty-r1200 x64_static May 8 2022 23:45:52
[2022-09-07 15:55:55] using compression: none.
[2022-09-07 15:55:55] using null cipher.
[2022-09-07 15:55:55] number of supernodes in the list: 1
[2022-09-07 15:55:55] supernode 0 => 118.31.12.101:7654
[2022-09-07 15:55:55] WARNING: encryption is disabled in edge
[2022-09-07 15:55:55] successfully created resolver thread
[2022-09-07 15:55:55] successfully created port mapping thread
[2022-09-07 15:55:55] automatically assign IP address by supernode
[2022-09-07 15:55:55] send REGISTER_SUPER to supernode [118.31.12.101:7654] asking for IP address
[2022-09-07 15:55:58] send REGISTER_SUPER to supernode [118.31.12.101:7654] asking for IP address
[2022-09-07 15:56:01] send REGISTER_SUPER to supernode [118.31.12.101:7654] asking for IP address
[2022-09-07 15:56:04] send REGISTER_SUPER to supernode [118.31.12.101:7654] asking for IP address
[2022-09-07 15:56:07] send REGISTER_SUPER to supernode [118.31.12.101:7654] asking for IP address
[2022-09-07 15:56:10] send REGISTER_SUPER to supernode [118.31.12.101:7654] asking for IP address
一直在询问ip 不分配ip地址,请问这是怎么回事?如何解决呢?麻烦作者大大了。
@小张
之前也有朋友反映过asking for IP address的问题,有几个疑惑:
1.sn端参数有没有指定分配的IP段?如果有,分配IP段是否配置正确?
2.不使用自动分配IP的话,edge端自定义虚拟IP是否成功?
@小张
那个,我也是遇到这个问题,然后搞了一个小时,原因是因为云服务端口放行默认的是TCP协议把TCP改成UDP即可
-bash: supernode: command not found
这是怎么回事
大佬,服务器报ERROR: n2n_seed faced error errno=38 from getrandom syscall.是啥错误啊
请问一下 WINDOW V3版本 服务端开启不了怎么办 点击开启之后马上停止了
@mxld
命令行执行,看看是否报错
“你的EasyN2N路径\n2n_client\x64\supernode_v3_bugxia_n2n.exe” “你的EasyN2N路径\n2n_client\supernode.conf”