I'm working on a custom Linux OS (built with Yocto) and I have two internet sources, one is GSM and another one is Wi-Fi. GSM is handled with PPP connection (ppp0 interface) and for Wi-Fi I use wpa_supplicant
on wlan0 interface. I can switch between AP and client mode on wlan0 interface. Whenever I switch to client mode, and I'm already connected with pppd, my device still uses GSM by default, it means it still consume data transfer form SIM card instead of Wi-Fi. To use Wi-Fi as a network source I have to stop pppd and do dhclient -v -1 wlan0
I would like to set up a connection with some kind of prioritizing. When I'm connected to Wi-Fi network and there is Internet access, use Wi-Fi as a source of the network, otherwise use GSM. Now it looks like it works the other way around.
I tried with setting metric value (equal to 0) on networkd
or as a route
parameter but, what is interesting, I have ppp0 metric set as 0 by default, but the command I use to set it up is route add default dev $PPP_IFACE metric 1
Here is my route output:
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default * 0.0.0.0 U 0 0 0 ppp0
default * 0.0.0.0 U 1 0 0 ppp0
10.8.8.0 * 255.255.255.0 U 0 0 0 proxy
10.64.64.64 * 255.255.255.255 UH 0 0 0 ppp0
192.168.1.0 * 255.255.255.0 U 0 0 0 wlan0
192.168.77.0 * 255.255.255.0 U 0 0 0 br0
Can somebody explain to me how to set it up to get my target setup?
iptables
and policy routing are out of the question, then you could useifmetric
to change the metric value of an existing route. Supposedly you have 2 routes, appp0
and awlan0
, both with meric0
. If you want to downgrade, let's sayppp0
, runifmetric ppp0 800
(or any number higher that the metric ofwlan0
) andppp0
will get route priority.