编辑于 2022 年 3 月 15 日:配置信息已添加到本问题末尾。我在 Google Cloud VPN 上安装了 WireGuard VPN,但由于网络费用,我在 DigitalOcean 上设置了一个新的。出于某种原因,我无法在任何设备上使用 SSH、VNC 或 SMB,但我的公共 IP 地址似乎可以正常工作。
这是与 DigitalOcean 相关的问题吗?或者有任何故障排除建议吗?
这是我尝试通过 SSH 连接到与 DigitalOcean Ubuntu Droplet 对等的另一个设备时遇到的错误示例:
ssh: connect to host 10.0.0.5 port 22: Operation timed out
DigitalOcean 服务器上的 wg0.conf:
[Interface]
Address = 10.0.0.1/24
SaveConfig = true
PostUp = ufw route allow in on wg0 out on eth0
PostUp = iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
PostUp = ip6tables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
PreDown = ufw route delete allow in on wg0 out on eth0
PreDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
PreDown = ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
ListenPort = 51820
PrivateKey = eHXOyd8**REMOVED FOR SECURITY**xMO9mlc=
[Peer]
PublicKey = wk6iHe+FiJhIV+wLxeCVLyWdT/WV8xrLmeHI39m5v2o=
AllowedIPs = 10.0.0.2/32
Endpoint = 104.228.167.16:51820
[Peer]
PublicKey = /OEck40Kjc15a3JzePkf9wmlMw+Sdzgaauhfzt/3LkM=
AllowedIPs = 10.0.0.3/32
Endpoint = 104.228.167.16:55239
[Peer]
PublicKey = CgHsJnocl8CkpD0c4rqFPmOBbpNB8Wpx0hy6J0YhBj0=
AllowedIPs = 10.0.0.4/32
Endpoint = 104.228.167.16:59555
[Peer]
PublicKey = wxW/6x/M8msXWqahcAR7OjpZbXsZta18qMHGMvbKaRg=
AllowedIPs = 10.0.0.5/32
Endpoint = 104.228.167.16:52628
PersistentKeepalive = 25
运行结果sudo ufw status
:
root@wireguard:~# sudo ufw status
Status: active
To Action From
-- ------ ----
51820/udp ALLOW Anywhere
OpenSSH ALLOW Anywhere
51820/udp (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
Anywhere on eth0 ALLOW FWD Anywhere on wg0
Anywhere (v6) on eth0 ALLOW FWD Anywhere (v6) on wg0
我的 iMac 配置(尝试通过 SSH、VNC 和 SMB 进入树莓派): 应用程序仪表板的屏幕截图
以及 Raspberry Pi(网络服务器)wg0.conf 文件:
[Interface]
PrivateKey = 0B26+xT9D4ZxOD23IeOPvh7gApOL5ES5NdXES/l7Lkk=
Address = 10.0.0.5
[Peer]
PublicKey = uj4QIUv4k40HK0nCGAtPKx8BYLUtWK8cTvLGOADkzx4=
AllowedIPs = 0.0.0.0/0
Endpoint = 142.93.113.242:51820
PersistentKeepalive = 25
这是我的 DigitalOcean 仪表板的屏幕截图: DigitalOcean VM 仪表板
答案1
感谢评论中的一位用户,允许防火墙通过 VPN 接口路由流量解决了这个问题。