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?
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 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.