Skip to content

Mikrotik Notes

Mikrotik DHCP client recursive route install script

# on the DHCP client def, use this script in the advanced tab
:if ( $bound=1) do={
  :log info ("*** DHCP bound, got gateway " . $"gateway-address")
  /ip route remove [ find comment="DEF1" ]
  /ip route remove [ find comment="REC1" ]
  /ip route add dst-address=8.8.8.8/32 gateway=($"gateway-address") comment="REC1" scope=10 target-scope=10 distance=1
  /ip route add dst-address=0.0.0.0/0 gateway=8.8.8.8 comment="DEF1" check-gateway=ping distance=1 target-scope=11
} else={
  :log info "*** DHCP unbound"
  /ip route remove [ find comment="DEF1" ]
  /ip route remove [ find comment="REC1" ]
}