场景: 我是在 A ( lan 192.168.1.0/24 ) B(192.168.88.0/24) 两处都部署了 wiregurd 希望从外网可以链接 A B 的局域网。
现象: 我节点 C 在外网是可以顺利链接 A B 任意一个的 lan 都是没有问题的。 BUT !!! 节点 B 内网无法访问 节点 A 反之也是!!!!
求问: 这该咋排查。。。
![]() | 1 Jimmyisme 2024-04-12 10:27:32 +08:00 一般都是 allowips 的锅 |
2 ghostwwg OP @Jimmyisme 应该木有问题,外网 C 是能顺利访问的。附上我的 allowips 配置 节点 A: --- 配置节点 B 的信息: AllowedIPs = 10.252.1.1/32, 192.168.88.0/24 ---- 节点 B: --- 配置节点 A 的信息: AllowedIPs = 10.252.1.2/32, 192.168.1.0/24 ---- |
3 Damn 2024-04-12 10:44:43 +08:00 via iPhone 还有路由表。OpenWrt 有一个选项可以自动添加,点点点即可,非 OpenWrt 可能需要手动添加路由。 |
4 bobryjosin 2024-04-12 10:45:28 +08:00 via Android 在哪个系统部署的,配置文件贴出来 |
5 csdreamdong 2024-04-12 10:57:23 +08:00 C 节点,要开 ip_forward ,以及 C 上面的要有去 A 和 B 的路由 |
![]() | 6 Ipsum 2024-04-12 11:22:06 +08:00 如果 c 可以访问到 ab ,那 c 的 postrouting 添加出 wg 接口的伪装。因为 ab 没有对方的路由表 |
7 ghostwwg OP @bobryjosin 节点 A -------------- root@j1900:~# cat /etc/wireguard/wg0.conf # peer_201# Address updated at: 2022-08-13 02:04:21.28015476 +0000 UTC # Private Key updated at: 2022-08-12 11:34:22.54225801 +0000 UTC [Interface] Address = 10.252.1.2/32 ListenPort = 52320 PrivateKey = xxx MTU = 1450 PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o br0 -j MASQUERADE # ID: phone # Name: peer_C1 # Email: # Created at: 2022-08-13 02:03:42.226570346 +0000 UTC # Update at: 2022-08-13 02:03:42.226570346 +0000 UTC [Peer] PublicKey = xxx AllowedIPs = 10.252.1.3/32 # ID: yoga # Name: peer_C2 # Email: # Created at: 2022-08-13 02:04:00.216322658 +0000 UTC # Update at: 2022-08-13 02:04:00.216322658 +0000 UTC [Peer] PublicKey = xxx AllowedIPs = 10.252.1.4/32 # ID: business tmp # Name: peer_C3 # Email: # Created at: 2023-05-30 02:04:00.216322658 +0000 UTC # Update at: 2023-05-30 02:04:00.216322658 +0000 UTC [Peer] PublicKey = xxx AllowedIPs = 10.252.1.5/32 # ID: dev_ub2004 # Name: peer_C4 # Email: # Created at: 2023-05-30 02:04:00.216322658 +0000 UTC # Update at: 2023-05-30 02:04:00.216322658 +0000 UTC [Peer] PublicKey = xxx AllowedIPs = 10.252.1.6/32 # ID: cbrgd76jimivehamds2g # Name: peer_403 # Email: # Created at: 2022-08-13 02:04:12.49288016 +0000 UTC # Update at: 2022-08-13 05:02:27.105906129 +0000 UTC [Peer] PublicKey = xxx AllowedIPs = 10.252.1.1/32, 192.168.88.0/24 Endpoint = ddnsXXX.space:52320 PersistentKeepalive = 25 -------------- 节点 B ------------- # peer_403 # Address updated at: 2022-08-13 02:04:21.28015476 +0000 UTC # Private Key updated at: 2022-08-12 11:34:22.54225801 +0000 UTC [Interface] Address = 10.252.1.1/32 ListenPort = 52320 PrivateKey = XXXX MTU = 1450 PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o br0 -j MASQUERADE # ID: phone # Name: peer_C1 # Email: # Created at: 2022-08-13 02:03:42.226570346 +0000 UTC # Update at: 2022-08-13 02:03:42.226570346 +0000 UTC [Peer] PublicKey = XXXXXX AllowedIPs = 10.252.1.3/32 # ID: yoga # Name: peer_C2 # Email: # Created at: 2022-08-13 02:04:00.216322658 +0000 UTC # Update at: 2022-08-13 02:04:00.216322658 +0000 UTC [Peer] PublicKey = xxx AllowedIPs = 10.252.1.4/32 # ID: business tmp # Name: peer_C3 # Email: # Created at: 2023-05-30 02:04:00.216322658 +0000 UTC # Update at: 2023-05-30 02:04:00.216322658 +0000 UTC [Peer] PublicKey = xxx AllowedIPs = 10.252.1.5/32 # ID: dev_ub2004 # Name: peer_C4 # Email: # Created at: 2023-05-30 02:04:00.216322658 +0000 UTC # Update at: 2023-05-30 02:04:00.216322658 +0000 UTC [Peer] PublicKey = xxxxx AllowedIPs = 10.252.1.6/32 # ID: xxxxxxx # Name: peer_201 # Email: # Created at: 2022-08-13 02:04:12.49288016 +0000 UTC # Update at: 2022-08-13 05:02:27.105906129 +0000 UTC [Peer] PublicKey = xxxx AllowedIPs = 10.252.1.2/32, 192.168.1.0/24 Endpoint = ddnsxxxxA.space:52320 PersistentKeepalive = 25 ------------ |
8 ghostwwg OP @csdreamdong 节点 C 就是 PC ,能正常访问 A B 两个节点的局域网,但 AB 局域网无法互相访问。。 |
9 ghostwwg OP @Ipsum 有 节点 A ----------- root@j1900:~# ip r|grep 88 192.168.88.0/24 dev wg0 scope link ----------- 节点 B ---------------- root@wuwg-EQ:~# ip r|grep 1.0 169.254.0.0/16 dev br0 scope link metric 1000 192.168.1.0/24 dev wg0 scope link --------------- |
![]() | 11 Ipsum 2024-04-12 13:56:43 +08:00 ddnsXXX.space:52320 这是节点 c ? |
![]() | 12 Ipsum 2024-04-12 14:04:39 +08:00 试试 把 iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE 改成 iptables -t nat -A POSTROUTING -o wg0 -j MASQUERADE |
13 ghostwwg OP |
![]() | 14 Ipsum 2024-04-12 14:50:19 +08:00 via Android sysctl -a |grep forward 看看 |
![]() | 15 guanzhangzhang 2024-04-12 15:20:44 +08:00 节点 c 的 wg 写 peer A allowIPs= A 的局域网 peerb allowIPs= B 的局域网 要开 forward 和 snat |
![]() | 16 Qetesh 2024-04-12 16:02:31 +08:00 用 wg 看下,很大可能 A-B 不通 |
17 Dzsss 2024-04-12 17:17:08 +08:00 OSPF 解君愁。A B 都上 MikroTik ,然后 A B 跑 OSPF 。 |
18 fuckshiter 2024-04-12 17:35:02 +08:00 把 wg-quick interface 搞上来看看 |
19 ghostwwg OP @Qetesh 现在就是节点 A <--> B 不通,但作为对外服务的 wg 节点(AB),我的客户端 C ( pc )是可以链接 AB 两个节点的. |
21 wxhwz 2024-04-13 01:50:11 +08:00 描述有点模糊没看明白,假设节点 a 、b 之间能互相访问,但下面内网 a 其余机器无法访问内网 b 因为流量从 br0 到节点 a ,然后通过 wg0 传到 b ,现在是断在这一步 所以 a 主机在原基础上需要加一个 iptables -t nat -I POSTROUTING -o wg0 -j MASQUERADE |
22 ghostwwg OP @wxhwz 接点 A B 是有公网 IP 对外提供接入服务的, - 节点 C 是客户端( PC )链接后能访问 A \ B 的局域网, - 但是! 节点 A 和节点 B 无法互相访问(捂脸哭泣。。。 |
24 wxhwz 2024-04-13 20:33:16 +08:00 @ghostwwg #22 A 配置文件中 [Interface] Address = 10.252.1.1/32 改成 Address = 10.252.1.1/24 B 主机同理 如果还是不行的话,检查下密钥有没有配错 |
25 Andy1989 2024-04-15 23:02:43 +08:00 @ghostwwg #2 我觉得你好像需要在你的节点 A AllowedIPs 里面加上 192.168.1.0/24 , 然后在节点 B 的 AllowedIPs 里面加上 192.168.88.0/24 吧。 |
26 ghostwwg OP @guanzhangzhang 节点 C (客户端)是这么写的,是可以链接 A B 的,但 A B 互相不通。。 |
27 ghostwwg OP @Andy1989 这个有的,节点 C 能访问 A B 我判断 A B 的 wg 服务是正常能对外提供链接的,但 AB 又不能互联,我 check 了他们( AB )的配置文件。。。又没找到什么问题。。 |
![]() | 28 guanzhangzhang 2024-04-26 09:24:29 +08:00 @ghostwwg #26 ping 的时候抓包看看 |