如何通过n2n实现内网穿透,在外面也能访问家里的电脑

GitHub - ntop/n2n: 点对点 VPN

推荐:

1 下载n2n并解压到/usr/local/n2n
2 创建supernode配置文件/usr/local/n2n/supernode.conf
3 创建edge配置文件 /usr/local/n2n/edge.conf
4 创建supernode服务 /etc/systemd/system/supernode.service或者/usr/lib/systemd/system/supernode.service
5 设置supernode开机启动 systemctl enable supernode --now
6 设置edge开机启动 systemctl enable edge --now

supernode部署

直接下载:

https://github.com/lucktu/n2n.git

源码编译:

./autogen.sh
./configure
make
​
# optionally install
make install

配置服务:

vi /etc/n2n/supernode.conf # 配置文件
-p 2345

服务:

/etc/systemd/system/supernode.service

[Unit]
Description=N2N SuperNode Run On Port 2012 UDP
After=network.target
​
[Service]
Type=simple
ExecStart=/usr/sbin/supernode /etc/n2n/supernode.conf -f
TimeoutStartSec=0
​
[Install]
WantedBy=default.target

edge

windows可能需要安装https://build.open.net/downloads/releases/tap-windows-9.21.0.exe

/usr/local/n2n/edge -c mynetwork -k mysecretpass -a 192.168.100.5 -l 124.221.191.89:2345

服务:

cat > /etc/systemd/system/edge.service << END
[Unit]
Description=n2n edge
Wants=network-online.target
After=network-online.target
​
[Service]
ExecStartPre=/bin/sh -c 'until ping -c1 124.221.191.89; do sleep 1; done;'
ExecStart=/usr/local/n2n/edge /usr/local/n2n/edge.conf -f
​
[Install]
WantedBy=multi-user.target
END

配置文件:

$ vi /usr/local/n2n/edge.conf
-c=mynetwork
-k=mysecretpass
-a=192.168.100.5
-l=124.221.191.89:2345

原文章:如何通过n2n实现内网穿透,在外面也能访问家里的电脑 - 汇思班

你可能感兴趣的:(linux,centos)