I currently have a setup where my rpi 3b (raspbian jessie), is connected to two routers, using eth0 and wlan0. I want to using eth0 only to communicate with another device in tha LAN. And i want to use wlan0 for WAN traffic via the router.

  • RPI eth0 -> router A -> Device in LAN. (RPI assigned IP in range 10.x.x.x)
  • RPI wlan0 -> router B -> any WAN traffic. (RPI assigned static IP

is it enough to use the route command, something like this below?

sudo route del default
sudo route add default gw (let's say this is the IP address of the router i want to use for internet)

however i was advised to avoid using the route command, since it is overwritten by most network configuration commands.

1 Answer 1


I'm not sure what you mean by route command being overwritten by config, but you can use ip command instead (from iproute* package):

sudo ip route replace default via
sudo ip route flush cache

Both commands manage (view/edit) routing table entries.

A bit of advice - you can have the ethernet interface manually configured without setting a default gateway on it (just an ip address and manual/dynamic routing if necessary). If that's not an option you can configure dhcp client to reject default gateway option on that interface (eth0).

  • Thank you for your answer. The issue with route, or ip route as you suggested, is that the changes do not seem to be permanent. If i reboot the device, or unplug and plug back the ethernet cable, all goes back as it was, with eth0 being the "preferred" interface and assigned with lowest metric. I am researching on the other 2 options you suggested. Thanks again Jun 14, 2018 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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