On Ubuntu 21.10, I have a cellular modem connected via USB that I need to be the primary interface on which all network traffic utilizes. However, I also need the wifi interface (in my case, wlo1
) to also continue to work, and be the backup in case the ppp0 interface goes down.
ping google.com -I ppp0
-> works through ppp
ping google.com -I wlo1
-> works though wifi
ping google.com
-> works through ppp (this is the difficult part)
I can get the cellular modem online just fine using pppd and corresponding scripts, and get a valid IP address. It's the routing I seem to be struggling with.
What I've tried
pppd
I first tried utilizing options in the PPP script, options like defaultroute
and replacedefaultroute
. defaultroute
does not alter the routing table and add a default route at all. Perhaps this is because, as I've come to learn, a routing table can only have one default route. Not sure. When trying to use the replacedefaultroute
option, pppd does add a default entry into the main routing table, however, this winds up breaking both interfaces and I have no internet connection whatsoever. It does not remove the existing default route for wifi, thus there exist two default routes in the main routing table.
Manually adding routes
I then played around with adding routes to the main routing table manually. Whan I run sudo ip route add {ipAddress} dev ppp0 src {ipAddress}
, then both interfaces work, but wifi is still the primary interface. Attempting to add that route with a metric lower than the wifi's metric also does not make it so that the ppp interface is primary (i.e. ping google.com
still goes out via wifi). I can add a second default, but it must have a metric higher than wifi, else it causes both connections to stop working.
A second routing table
Following other stack exchange posts and articles like this one, I explored the option of having two routing tables and adding a route and a default route the second routing table. While this doesn't break either connection, even using a metric lower than the wifi's metric, the ppp interface still is not the primary interface. Also, if I disconnect from wifi, then the ppp interface stops working as well, and the 2nd routing table is cleared (is this NetworkManager doing this?)
Questions
Is what I am trying to accomplish even possible? If so, what am I doing wrong? Am I fighting with NetworkManager?
Any help is greatly appreciated!