开始
于终端运行以下命令以编译安装N2N:
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
若为国内环境且无法连接至Github,替换2、3行:
apt-get install autoconf make gcc -y
wget https://blog.kdrnn.online/ctt/n2n-3.0.tar.gz
tar xzvf n2n-3.0.tar.gz
cd n2n-3.0
./autogen.sh
./configure
make && make install挂个systemd吧:
vim /etc/systemd/system/supernode.service
内容改为:
[Unit]
Description=n2n supernode daemon
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/root/n2n-3.0
ExecStart=/root/n2n-3.0/supernode -p 34567 -a 10.3.0.0-10.3.255.0/24 -f
Restart=always
RestartSec=5s
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
根据需要酌情修改ExecStart字段,上面仅给出基础运行参数(34567端口,10.3.0.0-10.3.255.0/24IP段)
systemctl daemon-reload
systemctl start supernode
systemctl status supernode
启动项基础用法:
supernode <配置文件> # 从配置文件加载参数(如 supernode.conf)
supernode [参数选项...] # 直接通过命令行参数配置
参数说明:
-p <端口> 指定本地监听端口
-l <主机:端口> 连接到其他Supernode
-F <名称> 指定社区网络名称(默认随机,建议自定义)
-M 禁用MAC/IP欺骗保护(仅测试用,生产环境不推荐)
-c <文件> 从文件加载社区列表(社区名+密码)
-a <起始IP>-<结束IP>/<掩码> 指定分配给客户端的IP范围(如 10.3.0.0-10.3.255.0/24)
-f 前台运行(适合systemd托管)
-u <UID> 指定运行用户ID
-g <GID> 指定运行组ID
-t <端口> 启用管理API端口
--management-password <密码> 设置管理API密码
-v 详细日志(可重复使用如 -vv 增加日志级别)
-V <版本文本> 自定义版本标识