Only providing default gateway if installed.

I have a DHCP instance that is providing a default gateway even when it is not appropriate to do so (such as the case where the router itself has no default route installed). Is there some setting to suppress the addition of this gateway option if the router does not have a default route installed? I’m looking for something similar to how in a BGP instance you can set default-originate=if-installed and dynamically add or drop the default route from advertisements.

Are you referring to DHCP client? If so there’s an option to add default route, just untick that. You’ll then need to work out how to create an alternative. In this scenario is the next hop fixed and known?

Starlink is an example. When its online the gateway address where you need to point your default route will always be 192.168.1.1 (or 10.64.0.1 if in bypass mode). However when first booted, before the Internet is established, Starlink gives out a gateway address that does not work, so you definitely don’t want that automatically added by DHCP.

Sorry I could have been clearer. I’m actually talking about the RouterOS DHCP server. I want to choose whether or not to send a gateway attribute on if the router has a default route itself, because what happens now is the router will happily declare itself the route of last resort to a client even if it is an island. When a client is connected to both the wired network homed to the RouterOS box and a distinct wifi network that has internet on it (think cellphone hotspot) the wired route wins even though it doesn’t go anywhere. I can always delete the route by hand, but I’m trying to make this whole approach a bit more automated.

I can’t recall if not having a gateway= setting under /ip dhcp-server network omits a gateway being sent, certainly the Mikrotik will make up DNS servers if there is no entry unless the No DNS option is set.

If it does there seems little point in changing it with a script based on external gateway reachability as once the client has received that information it will continue to use it until the next DHCP refresh, changing what the server will send makes no immediate change. You could set a rediculously short DHCP refresh period so you only have to wait say 30 seconds to a minute, but that will drain power on mobile devices as they will constantly be waking to refresh the network connection address.