Created
November 6, 2019 22:16
-
-
Save shaposhnikoff/c3223b629748d947620f52dd924b3fcc to your computer and use it in GitHub Desktop.
mikrotik two WAN backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ip firewall mangle | |
# mark incoming connections (same rules cover both traffic for router and traffic forwarded to LAN) | |
add action=mark-connection chain=prerouting connection-mark=no-mark \ | |
in-interface=ether1-primary new-connection-mark=conn_primary passthrough=no | |
add action=mark-connection chain=prerouting connection-mark=no-mark \ | |
in-interface=ether2-backup new-connection-mark=conn_backup passthrough=no | |
# jump to another table for all potentially outgoing connections | |
add action=jump chain=output jump-target=routing | |
add action=jump chain=prerouting in-interface=LAN jump-target=routing | |
add action=jump chain=prerouting in-interface=WIFI jump-target=routing | |
# no need to process packets which are not going out through any ISP | |
add action=return chain=routing dst-address-type=local,broadcast,multicast | |
add action=return chain=routing dst-address-list="Internal LAN" | |
# set routing marks for marked connections | |
add action=mark-routing chain=routing connection-mark=conn_primary \ | |
new-routing-mark=main passthrough=no | |
add action=mark-routing chain=routing connection-mark=conn_backup \ | |
new-routing-mark=backup passthrough=no | |
# unmarked connections | |
add action=mark-routing chain=routing connection-mark=no-mark disabled=yes \ | |
new-routing-mark=backup passthrough=no comment="enable this to use backup isp" | |
add action=mark-routing chain=routing connection-mark=no-mark \ | |
new-routing-mark=main passthrough=no | |
# routes | |
/ip route | |
add dst-address=0.0.0.0/0 gateway=1.1.1.1 routing-mark=backup | |
add dst-address=0.0.0.0/0 gateway=2.2.2.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment