Reject DHCP lease

Hello!

I have a problem with my hAP AC3. Whenever my cable modem goes down, my MikroTik gets a 192.168.100.x IP from it instead of the WAN public address. Coming from pfSense, which had this option to reject DHCP leases from an IP, how can I get this done on RouterOS?

Link here for the option on pfSense: https://www.reddit.com/r/PFSENSE/comments/ldzd1k/pfsense_reject_dhcp_lease/?utm_source=share&utm_medium=android_app&utm_name=androidcss&utm_term=1&utm_content=share_button

Thank you!

If you receive an address from the 192.168.100.0 subnet, is the global network available?

Or rather, not even so. See, what gateway address your router is getting on the 192.168.100.0 network. I understand, that this address will be available only if there is no access to the global network. Therefore, through NetWatch, you can check. If this address is available, execute the dhcp client reset command on the required interface.

This is the first thing, that came to mind.

I have no clue how to do that, honestly. Any help with that?
Thank you so much!

Based on this:
http://forum.mikrotik.com/t/checking-my-ppoe-out1-and-ppoe-out2-ip-address-and-disable-if-equlal-to-private-ip-starts-with-10/161985/1

Paste this on DHCP Client / Advanced / Script

:if ($bound = 1) do={
    :local leaseIP $"lease-address"
    :local iname   [/interface get $interface name]
    :if ($leaseIP in 192.168.100.0/24) do={
        :log warning "I do not like $leaseIP provided by the DHCP Server on $iname, I am about to provoke a Release in 10 seconds."
        :delay 10s ; # this prevents excessive CPU usage
        /ip dhcp-client
        release [find where interface=$iname]
    } else={
        :log info "I like $leaseIP provided by the DHCP Server on $iname."
    }
}

While I have found this workaround which is similar but less efficient since it pings 8.8.8.8 continuously, I’m using yours because it’s much, much more efficient.

http://forum.mikrotik.com/t/wan-dhcp-lease-renew-abnormal-with-nbn/134216/1

Thank you so much for your quick reply! Tested and it’s working amazing!