Keep losing default route if link is momentarily lost

Hi all,

Does anyone know what would cause an OpenWRT 21.02 device to keep losing the default routes?

I have configured the device as a Wifi client with a static IP and a default gateway, both for IPv4 and IPv6. Everything works fine, but after a few hours the device stops routing traffic. Getting a console on it reveals that both the IPv4 and IPv6 default gateways have disappeared.

Restarting the network with /etc/init.d/network restart returns the default routes and everything starts working again, but I have to keep doing this every few hours.

I suspect what is happening is the Wifi link is momentarily dropping out (taking the default routes with it), and when the link is re-established the default routes are not being re-added.

I can reproduce the problem by running ip link set wlan0 down; ip link set wlan0 up. When the interface comes back, everything seems fine except for the missing default routes.

Is there any way to configure OpenWRT to restore the default routes upon link re-establishment?

My config for this interface is:

config interface 'wifi'
	option proto 'static'
	option ip6ifaceid 'eui64'
	option ipaddr '192.168.0.2'
	option netmask '255.255.255.0'
	option gateway '192.168.0.1'
	option device 'wlan0'
	list ip6addr '2001:db8:0:1c::2/64'
	option ip6prefix '2001:db8:0:1c::/62'
	option ip6gw '2001:db8:0:1c::1'

Trying to create a bridge with two legs - #2 by vgaetera

Ah, clever workaround, I'll give it a go, many thanks!

1 Like

Unfortunately it doesn't look like this is an option. It says in the bridge config not to add a wireless interface directly to the bridge but to select the OpenWRT interface in the wireless settings for the network. If I do that, it doesn't attempt to connect to the wireless network and the logs say radio0 (1837): Interface 0 setup failed: BRIDGE_NOT_ALLOWED.

If I manually enter the wireless interface into the bridge settings OpenWRT accepts it, but no traffic passes and brctl show says the Wifi interface was never added to the bridge.

If I change the wireless settings from Client to Client (WDS) then it does get added to the bridge according to brctl show, but then no traffic gets passed to the AP.

I can't change the AP to WDS mode at the moment so I guess using a bridge is only possible in AP mode, not when the wireless link is a client to another non-WDS network?

I think I might've worked it out.

I had set "Force link" in the interface's advanced settings to make sure all the IPv6 stuff got set even if the link hadn't come up yet, but this was a mistake, as it also means events like the interface going up and down are ignored.

Unticking "Force link" has fixed the problem. Now if I manually bring the link down and up again with ip link the default route is restored.

For the record I tried adding a static route in a different routing table, however this too was removed when the link went down, despite some discussion online saying the non-default routing tables keep the routes even if the link goes down.

Note that low-level commands like ip are typically outside of the netifd scope of control.
If you need to operate the interface manually, use ifup and ifdown,

Also if you need custom routing tables, it should be configured properly:
https://openwrt.org/docs/guide-user/network/routing/examples/pbr_netifd

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