how to comment a WANs as WAN1 in IP Route

Hi guys,

I have two ISPs internet services and both of them are DHCP. I have hEX RB750G. the simple configuration is below

ETH1-3 in the same bridge (LAN).
ETH4: WAN2 (ISP2 internet connected)
ETH5: WAN1 (ISP1 internet connected)

My question is how to auto comment ISP1’s uplink as WAN1 in IP Route 0.0.0.0/0 when ETH5 is plugged in and up . and comment ISP2 as WAN2 when ETH4 is plugged and up. I know I have to write script in DHCP CLIENT section to achieve it.
default route.png
the reason I want to do it because

  1. both of UPLINKs are only DHCP, not static IP.
  2. i want to setup the netwatch, and netwatch is up and down are based on the script by find comment=WAN1

below script i wrote on netwatch.

Monitoring Host IP: 8.8.8.8
UP:
/ip route enable [find comment=WAN1]
/ip firewall connection { remove [find] }

DOWN:
/ip route disable [find comment=WAN1]
/ip firewall connection { remove [find] }

any one knows how to do it? thanks in advance.

Maybe it is easier to search for a default route related to the interface when it changes? Something like

ip/route/find where (vrf-interface=wan1 and dst-address=0.0.0.0/0)

thank you, bro. I tried your given code, but it doesn’t work.
the 0.0.0.0/0 pop up in IP ROUTE is without commented it as WAN1.

What I mean was that rather than add a comment the route, saying it is WAN1, then just use the above command in netwatch.

If you insist on adding a comment you might be able to do so by adding a script that does it in the DHCP script client script.

that is what i am doing now, but my script i wrote doesn’t work. do you know how to write the script and place it to DHCP Client Script section.

thank you,

thanks, guys,

I found the answer in here and it works.

https://wiki.mikrotik.com/wiki/Manual:IP/DHCP_Client#Lease_script_example

thank you for your help, Bro. I found the answer in here.

https://wiki.mikrotik.com/wiki/Manual:IP/DHCP_Client#Lease_script_example