How to advertise routes when connection is up, but not when down?

My fiber connection has grown unreliable. I'm having to disconnect/reconnect my laptop from my LAN and tether/untether to my phone multiple times a day. This is a manual operation. I'd like to automate it more.

What I'd like to do is remove the default gateway info from the DHCP service and instead rely on a dynamic routing protocol that automatically advertises a route to the internet when my PPPoE connection is up, and stops when it is down. The problem is I don't know what to do or where to start.

Can anyone help me set this up? Thanks!

update: Clarified that I'm switching my laptop's connection between phone and LAN as my fiber internet connection goes down and up.

As far I know (see for instance) DHCP should be able to force a renew but nobody implemented it.
With IPv6 however you can have a really low life time of a default router but odhcp don't offer a trigger as far as I know. However bird2 is able to do so. See and it's trigger option, and for an explanation.
Maybe a watchdog script on OpenWrt could check the state, alter the DHCP config and restart odhcp but this also feels not that well either...
As your requirement is that your phone is involved, running ospf is not an option but would be able to achieve it.

1 Like

connect phone to the same router, as the fiber, and use the mwan3 package for fail over handling ?


I want to keep my phone nearby, which means I don't want to leave it connected to my router. So, I want to connect it to my laptop, but I want my laptop to have up-to-date information about the WAN connectivity of my router so it can make good routing decisions on its own.

I've figured out how to prevent the DHCP server from supplying a default gateway (add "list dhcp_option '3'" to the config dnsmasq section of /etc/config/dnsmasq.

Unfortunately it doesn't look like its advertising IPv4 routes. I'm not sure how to enable that.

See and

Option 3 sets the default gateway. You can chance that but as stated before you can not force a renew, so the client will get the new info only on a refresh.

If you only care about your laptop.... And it is a Linux or Unix then maybe consider to configure ospf and disable DHCP option 3 so you can get a default route via ospf. I assume your laptop is connected with a cable and you have both the cable connection and wifi simultaneously....

Another option could be: if your mobile plan allows multiple sim cards you could get a second one and a 3g/4g modem, connect it to your router and use mwan3 to failover.


Thanks for the replies.

I think my laptop (MacOS) will automatically incorporate routes received through common protocols, but I'm not sure how to get my OpenWRT gateway to advertise/announce it's routes.

I don't see much dynamic routing info at
I did find

For dynamic routing protocols on OpenWrt look into frrouting. This thread sparked interest so I searched a bit. Lots of routing protocols supported via frr:
opkg list |grep ^frr

A quick search of OpenWrt docs didn't yield much but there may be useful info at

Maybe you will find a common solution for your router and Mac if your router has the space to install something appropriate.

Alternatively, you could look at finding or developing a script that checks connectivity locally on your Mac and sets the default route to the path that is "up" or the preferred path if both are up. The script could sleep a while and repeat in a loop or get run as a cron job every minute etc.

P.S. - I have no experience with this stuff and only pass on info from searches I just did.

Frr is ok till nice if someone prefers Cisco style config. I would still recommend bird2. Bird also supports babel.

1 Like

I didn't recognize the link to bird2 that you posted as being route related. Looks interesting. :+1: