Disappearing default route

Most of the time my default route is on network.lan which is proto = static

occasionally another interface comes up, network.s21u, which is proto = dhcp

network.s21u is started at boot and trying to come up, but the other end is my
phones mobile hotspot which is usually off, so most of the time it's down.

when I turn my mobile hotspot on, network.s21u becomes active and deletes
network.lan default route and adds the one from dhcp. This is what I want
in that now internet traffic goes through network.s21u.

When I turn the hotspot off on my mobile phone, network.s21u goes down and
deletes its default route.

Now I have no default route, but I would like the original network.lan's default route to
be readded.

as far as 'ubus call network.interface.lan status' is concerned, the default route exists. I guess
it's dhclient that's deleting it directly from the routing table, openwrt knows it added the default route
and knows it didn't delete it, so assumes it's still there.

Is there a way through the web interface I can do what I want? ie, most of the time default route
is through network.lan, when I turn my mobile hotspot on, default route is through network.s21u,
when I turn my hotspot off, default route is through network.lan

A bit of google says I can use a script in /etc/hotplug.d/iface which I'd have no problems doing,
but I'd rather do it through the web interface so upgrades just work. in the past I've added scripts
to the file system and I forget I added them and they disappear during upgrades and it just
takes me some time digging around and trying to remember what I did 2 years ago.

1 Like
uci set network.lan.metric="1024"
uci commit network
/etc/init.d/network restart
2 Likes

ah man, all my typing and you fixed it without saying a word.
after setting the metric dhclient no longer deletes the route and everything just works.
many thanks.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.