I have:

  1. A Raspberry Pi 3B SBC
  2. I have a Huawei E5330 3G Wifi router connected to the Pi via USB
  3. I have a Wireless router connected to my internet line (fibre)
  4. I have set a static IP address for my Pi's connection to the internet Wifi router
  5. I can connect to the Pi using SSH using that static IP

I have the challenge that when the Pi tries to access the internet (e.g, when running sudo apt-get update), it uses the Huawei modem's connection.

I want it to use the fibre's Wifi router connection(not connect through the Huawei 3G one).

What I have tried:

  1. Ran $ sudo route add default gw wlan0 based on this answer

Ran netstat -rn, and got the following result, where is my fibre line's Wifi router and is my 3G router

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface         UG        0 0          0 wlan0         UG        0 0          0 enx001e101f0000         UG        0 0          0 wlan0   U         0 0          0 wlan0   U         0 0          0 enx001e101f0000

Then Ran rote

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         UG    0      0        0 wlan0
default         www.huaweimobil         UG    204    0        0 enx001e101f0000
default         UG    303    0        0 wlan0   U     303    0        0 wlan0   U     204    0        0 enx001e101f0000

I don't want to mess up the configs, if I haven't already, so any help would be appreciated on how I can make all internet requests to go through my fibre's Wifi router (

2 Answers 2


You have three default routes. Only one default route can be used. Which one is determined by the metric. The route with the lowest metric wins. You have used deprecated command route that sets a metric of 0 if not specified. Now it is somewhat unclear what a metric of 0 means. Does it have the highest priority? It seems not to be in all cases. I have found a discussion about this at In Linux, what metric has a route with no metric?. You should better use more up to date command ip route.

The best is you omit using metric 0 to avoid confusing. But with your problem you do not have to care about metric at all. You add a default route but instead you should delete one. There is already a default route to the internet router:

default         UG    303    0        0 wlan0

It has only a lower metric than the one to the USB 3G router so it isn't used. You should just delete the default route to the 3G router with:

rpi ~$ sudo ip route del default via dev enx001e101f000

Then you only have one default route to the internet router.

To make this persistent you have to modify /etc/dhcpcd.conf (I suppose you are using default network setup). Just add this two lines:

interface enx001e101f000

Here are some details about this Can I prevent a default route being added when bringing up an interface?.

  • Thank-you for responding. I had no idea the route command was depracted. Thanks for that....Sorry to also ask what may be somewhat obvious to you, but how is this done. How do I delete the default route. I am a total beginner in many things Raspberry and *nix.
    – tinonetic
    Commented Feb 24, 2019 at 19:36
  • 1
    @user919426 No problem :-) That's the Raspberry Pi made for. I have given you the command sudo ip route del .... But I also have updated the answer to configure it persistent in /etc/dhcpcd.conf.
    – Ingo
    Commented Feb 24, 2019 at 19:57
  • Thank-you for that and for the persistent config. Trying it out
    – tinonetic
    Commented Feb 24, 2019 at 20:02
  • It tells me inet address is expected rather than "www.huaweimobil". I assume I have to type sudo ip route del default via dev enx001e101f000... based on linux-ip.net/html/tools-ip-route.html#tools-ip-route-del
    – tinonetic
    Commented Feb 24, 2019 at 20:11
  • @user919426 Yes, seems I have given a wrong advice. Does it work with Check with ip route. It should show you only one default route.
    – Ingo
    Commented Feb 24, 2019 at 20:23

In addition to the comments by Ingo you should list how you set a static IP address (many people do this incorrectly) - or better still don’t set one.

This may prevent routing from working properly.

In general Ethernet interfaces are preferentially used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.