Openwrt 的 Wireguard 客户端问题

2021-03-15 00:51:48 +08:00
 xqdoo00o
Openwrt 是主路由,lan 网段是 192.168.1.0/24.
Wireguard 在 Openwrt 作为客户端 连接国内 vps 使用,网段是 10.0.1.0/24.
当 AllowedIps 是 0.0.0.0/0 时,网络正常,外网 ip 是 vps 的 ip.
把 AllowedIps 改为电脑 IP 192.168.1.145 后,电脑就断网了,甚至无法 ping 通网关 192.168.1.1 。
求教下 Openwrt 要怎么设置才只让电脑走 Wireguard,其他的设备不走?
2123 次点击
所在节点    问与答
5 条回复
billlee
2021-03-15 01:46:43 +08:00
这个需要策略路由

AllowedIps 是 wireguard 的节点 IP 白名单,是要设置成外网 IP 或 wildcard 地址的。
trepwq
2021-03-15 07:48:20 +08:00
只让电脑走 wireguard 为什么不用电脑客户端呢
xqdoo00o
2021-03-15 16:19:49 +08:00
@billlee
尝试 openwrt 上设置了下策略路由
iptables -t mangle -A PREROUTING -s 192.168.1.145 -j MARK --set-mark 100
ip route add default via 10.0.1.1 dev wg0 table pc
ip rule add fwmark 100 table pc
测试结果是电脑能上网,但是没有走 Wireguard,ip 还是电信 ip.
xqdoo00o
2021-03-15 21:44:30 +08:00
忘了在 openwrt 上设置 Allowed IPs = 0.0.0.0/0 了,还得把 Route Allowed IPs 关掉。
不用 iptables 也行
ip route add default via 10.0.1.1 dev wg0 table pc
ip rule add from 192.168.1.145 table pc
现在已经可以了
l18581707928
2021-11-27 14:47:13 +08:00
你好我也想要实现这样得需求 请问你具体是怎么解决得呢?

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

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

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

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

© 2021 V2EX