I have Ethernet eth0 and Wireless wlan0, each one connected on a different ISP.

If I disconnect eth0 /etc/resolv.conf is kept unchanged, in my case ATT, pointing at their 'private' 'dns-servers' (

My other network belongs to, in my case Comcast; Att is not happy lending their DNS servers to a competitor, so they block the access.

If I do a ifdown wlan0 && ifup wlan0 the communication is established again.

I may use public DNS like or, but I want a more generic fix to this issue.

dig | grep SERVER

Will add that not only DNS is at fault, also the default route is not updated as it should be.

  • In a Bash terminal, what is the output of route? In both states please, and IPs can be changed to protect the innocent (well so long as you're consistent), I'm asking because I think ya may have a sticky default route... RPis are really fond of their wired connections... Also if I remember correctly dhcpcd is what updates various network related things on Pis; hint that was my ticket (well combined with systemd) to happy multi-interface networking (with somewhat graceful failure modes), though my use-case's likely different. – S0AndS0 Apr 28 '19 at 1:45

I can't remember if Raspbian has /etc/network/interfaces I'll boot mine up (RPi2 wheezy) and check. But some linux distros (ubuntu) allow you to setup an iface with /etc/network/interfaces and specify a dns. Which can overwrite resolve.conf

Open terminal

sudo nano /etc/network/interfaces

you may see

iface eth0 inet static
    address 192.168.1.x
    gateway 192.168.1.x
    dns-search example.com  -- your domain, e.g. home    not required

iface wlan0 inet static
    address 192.168.2.x
    dns-search example.com  -- your domain, e.g. home    not required

This is assuming ISP 1 = 192.168.1.x and ISP 2 = 192.168.2.x

Then in terminal enter:

sudo /etc/init.d/network restart

This will assign each interface their ip address gateway and DNS.

| improve this answer | |
  • Well, obviously we can manually setup or do down/up on the other interface), but I don't think is correct to loose internet access when disconnecting one interface. Also this will not be a generic solution if, for example, you connect to a third network. Should be, like any modern O/S self healed. Also, the release is 'Jessie' and /etc/interfaces is sort of obsolete: when using DHCP configuration changed dramatically. – fcm Jan 8 '16 at 12:35
  • So then your interfaces should be left to setup its configuration automatically. As being automatic it will re-assign ip, subnet, gw and DNS automatically. Is that not happening for your pi? – allegory Jan 8 '16 at 18:10
  • Automatic configuration occur only during reboot, on disconnection the other interface is no automatically reconfigured. Also at DHCP renewal the info will be updated. – fcm Jan 9 '16 at 0:05

This is a faulty design, it's easy to fix doing some manual edits, however this should be on the basic design.

the temporary fix is just:

$ ifdown wlan0 && ifup wlan0

The problem

When disconnecting the interface that was assigned as the primary, the one holding the default route, the secondary interface, now primary, will not be assigned as default route. The default DNS assigned to the first interface will not be assigned to the default DNS of the newly primary interface.

So, we have two separate issues:

  1. Default route is not reassigned when the primary interface goes down.
  2. DNS servers are not replaced when switching potentially to another network. (not shown here)

Here is how to duplicate the problem and the (temporary) solution.

Initial state

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         UG    0      0        0 eth0       *        U     0      0        0 wlan0     *        U     0      0        0 eth0

Remove eth0 ('disconnect')

$ ifdown eth0

Route state

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface       *        U     0      0        0 wlan0

There is no default route, with gateway '*' only local ARP resolved access is allowed. Everything else, fail:

$ ping
connect: Network is unreachable
$ apt-get update
Err http://mirrordirector.raspbian.org jessie InRelease
  Could not resolve 'mirrordirector.raspbian.org'
Err http://raspberrypi.collabora.com wheezy Release.gpg
  Could not resolve 'raspberrypi.collabora.com'

Force wlan0 to restart

$ ifdown wlan0 && ifup wlan0
Killed old client process
Internet Systems Consortium DHCP Client 4.3.1
DHCPDISCOVER on wlan0 to port 67 interval 6
bound to -- renewal in 10082 seconds.

Back in business.

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         UG    0      0        0 wlan0       *        U     0      0        0 wlan0

$ ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=2 ttl=239 time=124 ms

--- ping statistics ---
4 packets transmitted, 1 received, 75% packet loss, time 3011ms
rtt min/avg/max/mdev = 124.021/124.021/124.021/0.000 ms

Note: '$' used for clarity as the command prompt.

| improve this answer | |
  • 1
    Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo Apr 22 at 18:34

Set up a pihole and don't use either of the ISP DNS servers, while blocking ads, malware and telemetry. This can then also be used to protect other devices in your network.

| improve this answer | |

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.