brandoncheah
Posts: 28
Joined: Thu Sep 27, 2018 9:52 am

Prioritizing Wi-Fi (wlan0) over 3G USB Dongle (ppp0) internet connectivity

Wed Nov 28, 2018 9:31 am

I just bought a 3G USB Dongle (Huawei E173) and successfully configured it to have 3G internet connection using sakis3G and also UMTSkeeper to keep my 3G connection alive whenever any 3G disconnection happens.

I have both 3G and Wi-Fi connected at the same time. I want to only use 3G connection only whenever the Wi-Fi is down.
However, I realize that it uses the internet from the 3G connection instead of Wi-Fi. (For example, I opened a youtube video on chromium and I can see my mobile quota is being used)

What I want to achieve is similar to what we have in our smartphones, where it will automatically uses Wi-Fi over 3G, whenever there is Wi-Fi available, and of course it will use 3G whenever Wi-Fi is down.

I've searched on network metric and edited the metric value in /etc/dhcpcd.conf but still it uses ppp0 over wlan0

Anybody knows how to prioritize Wi-Fi over 3G connection?

m1z23r
Posts: 11
Joined: Mon Apr 24, 2017 1:12 pm

Re: Prioritizing Wi-Fi (wlan0) over 3G USB Dongle (ppp0) internet connectivity

Wed Nov 28, 2018 3:04 pm

I think this is what you need.

Code: Select all

ip route show
ip route del default
ip route add default via 192.168.1.1 dev wlan0
Just change device to wlan0 / eth0 or which ever interface you want to use and set the IP address to be the gateway of that network interface.

FYI It's not permanent, meaning you'd have to repeat the steps on each boot and you would need some workaround for when the wifi is disconnected / connected while Pi is running. It's not much help but I think it's a good start :)

brandoncheah
Posts: 28
Joined: Thu Sep 27, 2018 9:52 am

Re: Prioritizing Wi-Fi (wlan0) over 3G USB Dongle (ppp0) internet connectivity

Thu Nov 29, 2018 6:51 am

m1z23r wrote:
Wed Nov 28, 2018 3:04 pm
I think this is what you need.

Code: Select all

ip route show
ip route del default
ip route add default via 192.168.1.1 dev wlan0
Just change device to wlan0 / eth0 or which ever interface you want to use and set the IP address to be the gateway of that network interface.

FYI It's not permanent, meaning you'd have to repeat the steps on each boot and you would need some workaround for when the wifi is disconnected / connected while Pi is running. It's not much help but I think it's a good start :)
Thanks for your reply! I am now able to change the ip route by deleting default and adding the one as default to be connected to it using the following commands:

Code: Select all

sudo ip route del default  #to delete default route
sudo route add default gw "<router id>" #connect to wlan0 route

Return to “Advanced users”