说下环境,联通 3 条宽带,3 个 ipv4 公网属于同一 25 的的子网。
需求是
pppoe-out1 国内出站和入站
pppoe-out2 国内三网的 wireguard 入站和出站
pppoe-out3 国外策略路由的入站的出站
按常规的操作做了源进源出后,ipv6 没问题,ipv4 的 tcp 没问题,但是 ipv4 的 udp 会失败,导致基于 udp 的 wireguard 从 pppoe-out2 入站和出站失效。
后来浏览 mikrotik 的论坛,发现老外也提到这个问题
只需要建立三个策略路由表,出口分别是三个接口,最后在策略路由规则增加对应接口的地址即可。操作如下(省略了源进源出的 mangle 配置):
/routing table
add disabled=no fib name=pppoe-out1-routing
add disabled=no fib name=pppoe-out2-routing
add disabled=no fib name=pppoe-out3-routing
/ip route
add distance=1 dst-address=0.0.0.0/0 gateway=pppoe-out1 routing-table=pppoe-out1-routing scope=30 target-scope=10
add distance=1 dst-address=0.0.0.0/0 gateway=pppoe-out2 routing-table=pppoe-out2-routing scope=30 target-scope=10
add distance=1 dst-address=0.0.0.0/0 gateway=pppoe-out3 routing-table=pppoe-out3-routing scope=30 target-scope=10
/routing rule
add action=lookup comment=pppoe-out1 disabled=no src-address=你的 pppoe-out1 的公网地址 table=pppoe-out1-routing
add action=lookup comment=pppoe-out2 disabled=no src-address=你的 pppoe-out2 的公网地址 table=pppoe-out2-routing
add action=lookup comment=pppoe-out3 disabled=no src-address=你的 pppoe-out3 的公网地址 table=pppoe-out3-routing
最后在更新 ddns 脚本里加上一小段把这个 rule 更新下,所有问题修复了。
需求是
pppoe-out1 国内出站和入站
pppoe-out2 国内三网的 wireguard 入站和出站
pppoe-out3 国外策略路由的入站的出站
按常规的操作做了源进源出后,ipv6 没问题,ipv4 的 tcp 没问题,但是 ipv4 的 udp 会失败,导致基于 udp 的 wireguard 从 pppoe-out2 入站和出站失效。
后来浏览 mikrotik 的论坛,发现老外也提到这个问题
只需要建立三个策略路由表,出口分别是三个接口,最后在策略路由规则增加对应接口的地址即可。操作如下(省略了源进源出的 mangle 配置):
/routing table
add disabled=no fib name=pppoe-out1-routing
add disabled=no fib name=pppoe-out2-routing
add disabled=no fib name=pppoe-out3-routing
/ip route
add distance=1 dst-address=0.0.0.0/0 gateway=pppoe-out1 routing-table=pppoe-out1-routing scope=30 target-scope=10
add distance=1 dst-address=0.0.0.0/0 gateway=pppoe-out2 routing-table=pppoe-out2-routing scope=30 target-scope=10
add distance=1 dst-address=0.0.0.0/0 gateway=pppoe-out3 routing-table=pppoe-out3-routing scope=30 target-scope=10
/routing rule
add action=lookup comment=pppoe-out1 disabled=no src-address=你的 pppoe-out1 的公网地址 table=pppoe-out1-routing
add action=lookup comment=pppoe-out2 disabled=no src-address=你的 pppoe-out2 的公网地址 table=pppoe-out2-routing
add action=lookup comment=pppoe-out3 disabled=no src-address=你的 pppoe-out3 的公网地址 table=pppoe-out3-routing
最后在更新 ddns 脚本里加上一小段把这个 rule 更新下,所有问题修复了。