wireguard 布网故障

34 天前
 ghostwwg

场景: 我是在 A ( lan 192.168.1.0/24 ) B(192.168.88.0/24) 两处都部署了 wiregurd 希望从外网可以链接 A B 的局域网。

现象: 我节点 C 在外网是可以顺利链接 A B 任意一个的 lan 都是没有问题的。 BUT !!! 节点 B 内网无法访问 节点 A 反之也是!!!!

求问: 这该咋排查。。。

1909 次点击
所在节点    宽带症候群
28 条回复
Jimmyisme
34 天前
一般都是 allowips 的锅
ghostwwg
34 天前
@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
----
Damn
34 天前
还有路由表。OpenWrt 有一个选项可以自动添加,点点点即可,非 OpenWrt 可能需要手动添加路由。
bobryjosin
34 天前
在哪个系统部署的,配置文件贴出来
csdreamdong
34 天前
C 节点,要开 ip_forward ,以及 C 上面的要有去 A 和 B 的路由
Ipsum
34 天前
如果 c 可以访问到 ab ,那 c 的 postrouting 添加出 wg 接口的伪装。因为 ab 没有对方的路由表
ghostwwg
34 天前
@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

------------
ghostwwg
34 天前
@csdreamdong 节点 C 就是 PC ,能正常访问 A B 两个节点的局域网,但 AB 局域网无法互相访问。。
ghostwwg
34 天前
@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

---------------
ghostwwg
34 天前
@Damn 路由是有的
Ipsum
34 天前
ddnsXXX.space:52320 这是节点 c ?
Ipsum
34 天前
试试
把 iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE
改成
iptables -t nat -A POSTROUTING -o wg0 -j MASQUERADE
ghostwwg
34 天前
@Ipsum
带 ddns 的是节点 A 和节点 b

节点 C ( pc )走外网是能链接节点 A\B 的局域网的(捂脸
Ipsum
34 天前
sysctl -a |grep forward 看看
guanzhangzhang
34 天前
节点 c 的 wg 写

peer A
allowIPs= A 的局域网

peerb
allowIPs= B 的局域网

要开 forward 和 snat
Qetesh
34 天前
用 wg 看下,很大可能 A-B 不通
Dzsss
34 天前
OSPF 解君愁。A B 都上 MikroTik ,然后 A B 跑 OSPF 。
fuckshiter
34 天前
把 wg-quick interface 搞上来看看
ghostwwg
34 天前
@Qetesh 现在就是节点 A <--> B 不通,但作为对外服务的 wg 节点(AB),我的客户端 C ( pc )是可以链接 AB 两个节点的.
Qetesh
34 天前
@ghostwwg wireguard 是类似 Mesh 网络,全连接的状态。怀疑 AB 之间的认证的公私钥等有问题

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

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

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

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

© 2021 V2EX