大佬们,内网穿透哪种方案适合我?

317 天前
 mikaelson
首先,有云主机,也就是有公网 IP 了

我的环境是这样:

各地有散落的本地服务器,我希望能组个局域网,让所有地区的服务器都能自己设置个虚 ip ,然后互联。并且相关人员可以访问。

目前的方案是:
tinc 组网,然后云服务器对各个地区服务器的 22 端口进行转发,所有相关人员通过公网 ip+端口访问到各个服务器。
服务器之间的业务用虚 IP 连接。。。还有一些内网应用,通过映射端口让外部访问。

本来挺简单的把,最近不懂咋了,tinc 一直没速度,或者丢包,连正常的 ssh 都不稳了。我尝试更新到 1.1.18 版本改一些配置,还是这样。。。之前一直用的 1.0.36

所以来需求其他方案了。了解了一下能组网的也就 n2n ,zerotier ,tailscale ?哪个会比较适合?

大佬们给点建议呀。谢谢各位。
13524 次点击
所在节点    程序员
111 条回复
hancc
317 天前
WireGuard
hu8245
317 天前
tailscale/headscale wireguard 境内超稳
233373
317 天前
那必须是 wireguard
mikaelson
317 天前
@233373 只能是 wireguard 了嘛?流量容易被侦测嘛
bytesfold
317 天前
wireguard nat to nat
14
317 天前
我用 headscale 配合云服务器+权限控制关联几乎所有服务器、wireguard 跑在家里公网端口方便高速回家、zerotier 使用官方服务器作为保底方案。
Evovil
317 天前
各地有散落的本地服务器:
如果都有固定 ip 那么 wireguard 是最佳选择
如果没有固定 ip ,云服务器带宽足够,wireguard 是最好的选择。
wg 速度快性能好,内核兼容。前提是云服务器需要中转流量。运维方便。

如果需要服务器点对点连最大化利用带宽,服务器数量不多的情况下可以互相建立 wg 隧道,然后服务器用 ospf 等协议广播路由表,还能自动故障切换。

如果嫌麻烦 zerotier ,tailscale ,tinc 可以尝试

如果不需要 route subnet 直接用 wgip 访问即可,nat 都不需要。

如果遇到运营商 qos ( udp ) 可以套 udp2raw 或者 phantun (手动点对点)
Jirajine
317 天前
有一个公网 IP 的服务器好办,跑个 wireguard 让其他所有设备连上就行了。
其他设备之间的流量会自动发现 endpoint ,自动直连。
opengps
317 天前
我用最简单的 frp
Jirajine
317 天前
@Evovil wireguard 应该会自动发现动态 ip 的“客户端”的 endpoint ,也就是端点直连而非中转。( wireguard 设计里都是对等的,不分服务端客户端)。
以及组一个内网就用不上路由协议这种东西了吧。
mikaelson
317 天前
@opengps 这个就不适用了呀,适合映射单端口吧。
opengps
316 天前
@mikaelson 可以多端口,指定一批或者连续一段
yanzhiling2001
316 天前
请问一下各位大佬,这些组网工具,WireGuard zerotier ,tailscale/tailscale 等等,哪些是流量加密的。
loveqianool
316 天前
也可以试试 https://openp2p.cn/
webcape233
316 天前
wirguard 是最简单的了!
a33291
316 天前
最简单不是 softether 吗
233373
316 天前
@Jirajine wireguard 是中专不是点对点,点对点可以使用 headscale
datocp
316 天前
一直使用 softether ,之前也有这个需求没有深入研究
https://forum.vpngate.net/viewtopic.php?t=65656

现在网络是分级的,比如 2018 年时,电信联通网络不通,晚上两网之间连接竟然跑到省会城市去连接,搞得网间流量才 50KB/s 。出了墙更是有流量累积风险。移动访问深信服的 vpn 也是有间谒性访问问题的。

从这些年的经验来看,用 softether 常见避墙方法
1 。定时变更级联线路,条条大路通罗马
2 。同一服务器变更不同端口,以上都能有效的避开流量封锁
3 。似乎定时变更证书也能避墙

softether 的另外一个优点是一个服务器端即是服务器端又是客户端,具备一个服务器端连接全球服务器的效果,只是这需要对 linux route 有更高阶的经验。另外作者点拔了一下 softether 实现的 mesh ,只是没能领会用途。

之前测试时用的这种方法,softether 过墙的效果还是非常好的。

Webserver over VPN
https://forum.vpngate.net/viewtopic.php?t=65656

Sure. What I did was set up a TAP adapter on the server so the VPN server can ping the VPN cleint. After that I used software like HAProxy and iptables port-fowarding to make the web-server available to the public


Setup the VPN server (after creating the TAP adapter in the server control panel)
sysctl -w net.ipv4.ip_forward=1
service vpnserver start #if not started allready
dhclient tap_tap #get an IP for this TAP adapter

For a web server tho I suggest HAProxy so you can use HTTP headers to get client IP address. This part is a little complicated and if you are using multiple subdomains you might need a Wildcard SSL to use in HAProxy (which you can usually get for free from Let's Encrypt)

If you are running a Minecraft Server you can use HAProxy and a SpigotProxy plugin to get player's real IPs and it works well for a testing env.

Heres what I use on the VPN server for generic port forwarding. x.x.x.x represents the server's public IPv4 and 192.168.30.13 is my VPN Client's IP (this will prob. work for IPv6)

iptables -t nat -I PREROUTING 1 -d x.x.x.x -p tcp --dport 8081 -j DNAT --to-dest 192.168.30.13:8081
iptables -t nat -I POSTROUTING 1 -d 192.168.30.13 -p tcp --dport 8081 -j SNAT --to-source 192.168.30.1
iptables -I FORWARD 1 -d 192.168.30.13 -p tcp --dport 8081 -j ACCEPT


If you do get a Wildcard SSL thru Let's Encrypt. Use this command to combine the certs than use this command block to turn it into a single pem file to use with HAProxy

sudo cat /etc/letsencrypt/live/mydomain.tld/fullchain.pem \
/etc/letsencrypt/live/mydomain.tld/privkey.pem \
| sudo tee mydomain.tld.pem
mikaelson
316 天前
@opengps 那各个设备之间的互联呢?这样就没有虚 IP 来直接连接了吧。
mikaelson
316 天前
@14 跑公网端口的话,是走云服务器的带宽咯:?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/952217

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX