OpenWRT 策略路由求指导

41 天前
 microka
GL-MT6000 安装 ImmortalWrt 23.05.3 ,wan1/2/3 使用 mwan3 根据目标 IP 进行分流,运行一段时间后无法通过 wan3 IP 入站(如 RDP 入站,此时能通过 wan3 出站,但 wan3 网速、延迟都明显变差)( wan2 无公网 IPv4 无法测试)。

怀疑 mwan3 与 fw3(iptables)/fw4(nftables) 混用存在问题,尽管已经装了 iptables-nft ip6tables-nft

x86 + ImmortalWrt 23.05.3 也存在同样问题,x86 + ImmortalWrt 21.02.7 (防火墙为纯 iptables )则能保持稳定正常使用。

得知 pbr 可原生支持 nftables ,于是想从 mwan3 转到 pbr ,现在 pbr 出站策略还比较好配置,但非默认网关 wan 入站不知如何配置,比如默认网关是 wan1 ,想通过 wan3 IP 连接本地服务(源进源出),请问应如何配置?求指导,谢谢~
1309 次点击
所在节点    宽带症候群
9 条回复
titanium98118
41 天前
r5c ImmortalWrt 23.05.0-rc1 mwan3 ,距上次重启 50 天
没遇到你的问题,wan1 wan2 进站正常
microka
41 天前
@titanium98118 我 wan1 wan3 是同个光猫出来的,wan1 用 ImmortalWrt 拨号,wan3 试过用 ImmortalWrt 或者光猫拨号,都有这问题,x86 换回 ImmortalWrt 21.02.7 就没问题。折腾得心好累😂
microka
41 天前
@titanium98118 尴尬,我刚 21.02.7 也遇到同样问题了,过一会儿又恢复正常,我再好好排查下吧 😂
htfcuddles
41 天前
ImmortalWrt 23.05.0-rc3 mwan3 wtih fw4 运行挺久了,没遇到你说的问题,把 debug 信息贴出来看看
htfcuddles
41 天前
另外,入站一般不需要配置的,mwan3 的默认规则里有针对来源接口的路由,建议你看看 wiki:


1. Restore mark if previous set. If successful marked, goto step 5.
2. Check if the packet arrives on a wan interface. If originated from a local connected ip network, then mark packet with default iface_id. If the packet is from another (non-local) network and arrives on wan interface, then mark it with iface_id. If successful marked, goto step 5.
3. Check if packet destined for a known ip network (has a route for it other than default). If so then mark packet with default iface_id and goto step 5.
4. Check if packet source address is that of a wan interface. If so use that wan interface for routing regardless of user defined rules and mark packet with iface_id of corresponding wan.
5. Apply user rules and mark with configured iface_id. If no match leave unmarked.
6. If marked then save mark.
htfcuddles
41 天前
第 3 第 4 条就是入站来源的路由:


Output of "ip -4 rule show"
-------------------------------------------------
0: from all lookup local
1000: from all fwmark 0x162 lookup 354
1001: from all iif pppoe-wan1 lookup 1
1002: from all iif pppoe-wan2 lookup 2
2001: from all fwmark 0x100/0x3f00 lookup 1
2002: from all fwmark 0x200/0x3f00 lookup 2
2061: from all fwmark 0x3d00/0x3f00 blackhole
2062: from all fwmark 0x3e00/0x3f00 unreachable
3001: from all fwmark 0x100/0x3f00 unreachable
3002: from all fwmark 0x200/0x3f00 unreachable
32766: from all lookup main
32767: from all lookup default
htfcuddles
41 天前
mwan3 是用 policy routing 基于 fwmark 分流的,mangle 表里有相应规则。一个常见的问题是如果有其他插件设置了 fwmark ,需要改默认的 fwmask (#6 的 0x3f00 ),如果这个插件不支持 fwmask 那就是不兼容。openclash 就有这个问题,fw4 的处理有问题,需要魔改一下脚本
microka
41 天前
@htfcuddles mwan3 入站确实不需要怎么配置,我这也没装其他分流插件,我再折腾下,有需要再向您请教,感谢~
onetown
41 天前
源进源出很简单的, 就是为某个 wan 设置一个单独的路由表, 例如我电信的地址是 2.2.2.2 , 网关 2.2.2.1 , 我们需要
路由表:
ip r a default via 2.2.2.1 table 2

pbr:
ip rule add to 2.2.2.2 lookup 2

这样你就可以随便从哪里访问 2.2.2.2 了

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

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

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

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

© 2021 V2EX