[admin@kirilka] /ip firewall nat add chain=srcnat out-interface=ether1 action=masquerade comment="ISP 1" [admin@kirilka] /ip firewall nat add chain=srcnat out-interface=ether2 action=masquerade comment="ISP 2" [admin@kirilka] /ip firewall nat add chain=srcnat out-interface=ether3 action=masquerade comment="ISP 3"
[admin@kirilka] /ip firewall mangle> print Flags: X - disabled, I - invalid, D - dynamic 0 chain=input action=mark-connection new-connection-mark=ISP 1 -> Input passthrough=no dst-address=172.25.25.247 in-interface=ether1 1 chain=output action=mark-routing new-routing-mark=ISP 1 passthrough=no connection-mark=ISP 1 -> Input 2 chain=input action=mark-connection new-connection-mark=ISP 2 -> Input passthrough=no dst-address=192.168.99.2 in-interface=ether2 3 chain=output action=mark-routing new-routing-mark=ISP 2 passthrough=no connection-mark=ISP 2 -> Input 4 chain=input action=mark-connection new-connection-mark=ISP 3 -> Input passthrough=no dst-address=192.168.100.2 in-interface=ether3 5 chain=output action=mark-routing new-routing-mark=ISP 3 passthrough=no connection-mark=ISP 3 -> Input
[admin@kirilka] /ip firewall address-list> print Flags: X - disabled, D - dynamic # LIST ADDRESS 0 LocalNet 192.168.101.0/24 1 LocalNet 192.168.102.0/24
6 chain=prerouting action=mark-routing new-routing-mark=office 1 passthrough=no src-address=192.168.101.0/24 dst-address-list=!LocalNet
dst-address=0.0.0.0/0 gateway=172.25.25.1 check-gateway=arp distance=10 routing-mark=office 1 dst-address=0.0.0.0/0 gateway=192.168.99.1 check-gateway=arp distance=11 routing-mark=office 1 dst-address=0.0.0.0/0 gateway=192.168.100.1 check-gateway=arp distance=12 routing-mark=office 1
Retreat: there are many different scripts on the Internet, but most of them execute a script at a given time interval that changes the distance values ​​in the routes. We are not satisfied with this option as in MikroTik there is a NAND memory and it has its own recording limit. We will save it. Of course, it was possible to edit the script and make a check, but this is not our method. )
[admin@kirilka] /tool netwatch> print detail Flags: X - disabled 0 host=8.8.8.8 timeout=1s interval=1m status=up up-script=ISP1-UP down-script=ISP1-DOWN 1 host=8.8.4.4 timeout=1s interval=1m status=up up-script=ISP2-UP down-script=ISP2-DOWN
/ip route enable [find dst-address=0.0.0.0/0 and gateway=172.25.25.1 and distance >= 10];
/ip route disable [find dst-address=0.0.0.0/0 and gateway=172.25.25.1 and distance >= 10];
[admin@kirilka] > ip route add dst-address=8.8.8.8 gateway=172.25.25.1 [admin@kirilka] > ip route add dst-address=8.8.4.4 gateway=192.168.99.1
[admin@kirilka] > ip firewall mangle print Flags: X - disabled, I - invalid, D - dynamic 0 chain=input action=mark-connection new-connection-mark=ISP 1 -> Input passthrough=no dst-address=172.25.25.247 in-interface=ether1 1 chain=output action=mark-routing new-routing-mark=ISP 1 passthrough=no connection-mark=ISP 1 -> Input 2 chain=input action=mark-connection new-connection-mark=ISP 2 -> Input passthrough=no dst-address=192.168.99.2 in-interface=ether2 3 chain=output action=mark-routing new-routing-mark=ISP 2 passthrough=no connection-mark=ISP 2 -> Input 4 chain=input action=mark-connection new-connection-mark=ISP 3 -> Input passthrough=no dst-address=192.168.100.2 in-interface=ether3 5 chain=output action=mark-routing new-routing-mark=ISP 3 passthrough=no connection-mark=ISP 3 -> Input 6 chain=prerouting action=mark-routing new-routing-mark=office 1 passthrough=no src-address=192.168.101.0/24 dst-address-list=!LocalNet 7 chain=prerouting action=mark-routing new-routing-mark=office 2 passthrough=no src-address=192.168.102.0/24 dst-address-list=!LocalNet
[admin@kirilka] > ip route print detail Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, B - blackhole, U - unreachable, P - prohibit 0 AS dst-address=0.0.0.0/0 gateway=172.25.25.1 gateway-status=172.25.25.1 reachable via ether1 distance=1 scope=30 target-scope=10 routing-mark=ISP 1 1 AS dst-address=0.0.0.0/0 gateway=192.168.99.1 gateway-status=192.168.99.1 reachable via ether2 distance=1 scope=30 target-scope=10 routing-mark=ISP 2 2 AS dst-address=0.0.0.0/0 gateway=192.168.100.1 gateway-status=192.168.100.1 reachable via ether3 distance=1 scope=3> target-scope=10 routing-mark=ISP 3 3 AS dst-address=0.0.0.0/0 gateway=172.25.25.1 gateway-status=172.25.25.1 reachable via ether1 check-gateway=arp distance=10 scope=30 target-scope=10 routing-mark=office 1 4 S dst-address=0.0.0.0/0 gateway=192.168.99.1 gateway-status=192.168.99.1 reachable via ether2 check-gateway=arp distance=11 scope=30 target-scope=10 routing-mark=office 1 5 S dst-address=0.0.0.0/0 gateway=192.168.100.1 gateway-status=192.168.100.1 reachable via ether3 check-gateway=arp distance=12 scope=30 target-scope=10 routing-mark=office 1 6 AS dst-address=0.0.0.0/0 gateway=192.168.99.1 gateway-status=192.168.99.1 reachable via ether2 check-gateway=arp distance=10 scope=30 target-scope=10 routing-mark=office 2 7 S dst-address=0.0.0.0/0 gateway=172.25.25.1 gateway-status=172.25.25.1 reachable via ether1 check-gateway=arp distance=11 scope=30 target-scope=10 routing-mark=office 2 8 S dst-address=0.0.0.0/0 gateway=192.168.100.1 gateway-status=192.168.100.1 reachable via ether3 check-gateway=arp distance=12 scope=30 target-scope=10 routing-mark=office 2 9 AS dst-address=0.0.0.0/0 gateway=172.25.25.1 gateway-status=172.25.25.1 reachable via ether1 distance=1 scope=30 target-scope=10 10 AS ;;; Netwatch ->ISP2 dst-address=8.8.4.4/32 gateway=192.168.99.1 gateway-status=192.168.99.1 reachable via ether2 distance=1 scope=30 target-scope=10 11 AS ;;; Netwatch ->ISP1 dst-address=8.8.8.8/32 gateway=172.25.25.1 gateway-status=172.25.25.1 reachable via ether1 distance=1 scope=30 target-scope=10 12 ADC dst-address=172.25.25.0/24 pref-src=172.25.25.247 gateway=ether1 gateway-status=ether1 reachable distance=0 scope=10 13 ADC dst-address=192.168.99.0/24 pref-src=192.168.99.2 gateway=ether2 gateway-status=ether2 reachable distance=0 scope=10 14 ADC dst-address=192.168.100.0/24 pref-src=192.168.100.2 gateway=ether3 gateway-status=ether3 reachable distance=0 scope=10 15 ADC dst-address=192.168.101.0/24 pref-src=192.168.101.1 gateway=ether4 gateway-status=ether4 reachable distance=0 scope=10 16 ADC dst-address=192.168.102.0/24 pref-src=192.168.102.1 gateway=ether5 gateway-status=ether5 reachable distance=0 scope=10
[admin@kirilka] /system script> print Flags: I - invalid 0 name="ISP1-UP" owner="admin" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api last-started=jul/11/2013 05:07:34 run-count=9 source=/ip route enable [find dst-address=0.0.0.0/0 and gateway=172.25.25.1 and distance >= 10]; 1 name="ISP1-DOWN" owner="admin" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api last-started=jul/11/2013 04:47:03 run-count=2 source=/ip route disable [find dst-address=0.0.0.0/0 and gateway=172.25.25.1 and distance >= 10]; 2 name="ISP2-UP" owner="admin" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api last-started=jul/11/2013 05:08:01 run-count=1 source=/ip route enable [find dst-address=0.0.0.0/0 and gateway=192.168.99.1 and distance >= 10]; 3 name="ISP2-DOWN" owner="admin" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api last-started=jul/11/2013 05:07:36 run-count=1 source=/ip route disable [find dst-address=0.0.0.0/0 and gateway=192.168.99.1 and distance >= 10];
Source: https://habr.com/ru/post/186284/
All Articles