I've created script that should help solving a problem. It checks gateway of specified interface ($mInterface), looks for default routing rule that matches specified route mark ($mRoutingMark) and alters rule's gateway to match the one set for interface. If default routing rule does not exist, script creates it.
# name of interface that should be monitored
# (edit to match your interface name)
:set mInterface pppoe-adsl ;
# routing mark name used for default route that should be updated
# (edit to match your routing mark name)
:set mRoutingMark adsl-user ;
/ip address ;
:set mAddress [find interface=$mInterface] ;
:set mGateway [get $mAddress network] ;
/ip route ;
:set mGatewayFound 0
:foreach i in [find routing-mark=$mRoutingMark] do={ \
:set mDstAddress [get $i dst-address]; \
:set qResult [:find $mDstAddress "0.0.0.0/0"]; \
:if ($qResult = 0) do={ \
set $i gateway=$mGateway ; \
:put "gateway rule adjusted"; \
:set mGatewayFound 1; \
}; \
};
:if ($mGatewayFound = 0) do={ ; \
add dst-address=0.0.0.0/0 gateway=$mGateway routing-mark=$mRoutingMark; \
:put "gateway rule added"; \
};
Question is, how to run this script other that scheduler? Is there a way that IP change on interface can triger this script?