GoForum🌐 V2EX

mikrotik ros7.x 版本路由多拨配置,自己记录一下

xiaoxiannv · 2026-06-11 19:03 · 0 次点赞 · 0 条回复

/ip firewall mangle remove [find] /ip firewall nat remove [find] /ip route remove [find dst-address=0.0.0.0/0] /interface pppoe-client remove [find name=pppoe1] /interface pppoe-client remove [find name=pppoe2] /routing table remove [find name=to-pppoe1] /routing table remove [find name=to-pppoe2] /system scheduler remove [find name=check-pppoe-failover]

/interface bridge port remove [find interface=WAN] /interface bridge port remove [find interface=LAN1] /interface bridge port remove [find interface=LAN2] /interface bridge port add bridge=bridge-lan interface=LAN1 /interface bridge port add bridge=bridge-lan interface=LAN2

/ip dns set allow-remote-requests=yes servers=***,***

/interface pppoe-client add name=pppoe1 interface=WAN ac-name=“*” user=”*” password=“*” add-default-route=no use-peer-dns=no disabled=no add name=pppoe2 interface=WAN ac-name=”*” user=“*” password=”*” add-default-route=no use-peer-dns=no disabled=no

/ip firewall nat add chain=srcnat out-interface=pppoe1 action=masquerade add chain=srcnat out-interface=pppoe2 action=masquerade

/routing table add fib name=to-pppoe1 add fib name=to-pppoe2

/ip firewall mangle add comment=PCC1 chain=prerouting in-interface=bridge-lan connection-mark=no-mark dst-address-type=!local per-connection-classifier=both-addresses-and-ports:20 action=mark-connection new-connection-mark=conn-pppoe1 passthrough=yes add comment=PCC2 chain=prerouting in-interface=bridge-lan connection-mark=no-mark dst-address-type=!local per-connection-classifier=both-addresses-and-ports:21 action=mark-connection new-connection-mark=conn-pppoe2 passthrough=yes add comment=ROUTE1 chain=prerouting in-interface=bridge-lan connection-mark=conn-pppoe1 action=mark-routing new-routing-mark=to-pppoe1 passthrough=no add comment=ROUTE2 chain=prerouting in-interface=bridge-lan connection-mark=conn-pppoe2 action=mark-routing new-routing-mark=to-pppoe2 passthrough=no

/ip route add dst-address=0.0.0.0/0 gateway=pppoe1 routing-table=to-pppoe1 distance=1 add dst-address=0.0.0.0/0 gateway=pppoe2 routing-table=to-pppoe2 distance=1 add dst-address=0.0.0.0/0 gateway=pppoe1 distance=1 add dst-address=0.0.0.0/0 gateway=pppoe2 distance=2

/system scheduler add name=check-pppoe-failover interval=10s on-event=“:local p1 [/interface get pppoe1 running]; :local p2 [/interface get pppoe2 running]; :if ($p1 && $p2) do={/ip firewall mangle enable [find comment=PCC1]; /ip firewall mangle enable [find comment=PCC2]; /ip firewall mangle enable [find comment=ROUTE1]; /ip firewall mangle enable [find comment=ROUTE2];}; :if ($p1 && !$p2) do={/ip firewall mangle enable [find comment=PCC1]; /ip firewall mangle disable [find comment=PCC2]; /ip firewall mangle enable [find comment=ROUTE1]; /ip firewall mangle disable [find comment=ROUTE2];}; :if (!$p1 && $p2) do={/ip firewall mangle disable [find comment=PCC1]; /ip firewall mangle enable [find comment=PCC2]; /ip firewall mangle disable [find comment=ROUTE1]; /ip firewall mangle enable [find comment=ROUTE2];};”

0 条回复
添加回复
你还需要 登录 后发表回复

登录后可发帖和回复

登录 注册
主题信息
作者: xiaoxiannv
发布: 2026-06-11
点赞: 0
回复: 0