Why does the wifi internet access fail shortly after connecting to a LAN without internet access

internetNetworkrouterwifi

I have a working wireless connection to an access point with an internet connection (where my IP is 172.17.30.137). Over this wireless connection I am able to ping internet addresses (e.g. 4.2.2.1) as well as other machines on the wifi network (e.g. 172.17.30.1). I leave those ping processes running in the background. Now I plug in an ethernet cable, which goes to a LAN on which there is a DHCP server but no internet access. That DHCP server assigns my ethernet adapter an IP (10.35.1.100) and I am now also able to ping addresses on that LAN (e.g. 10.35.1.1). All three pings run concurrently for a few seconds to a few minutes, when suddenly the ping to 4.2.2.1 does this:

64 bytes from 4.2.2.1: icmp_seq=1629 ttl=55 time=8.376 ms
64 bytes from 4.2.2.1: icmp_seq=1630 ttl=55 time=14.247 ms
64 bytes from 4.2.2.1: icmp_seq=1631 ttl=55 time=18.024 ms
Request timeout for icmp_seq 1632
Request timeout for icmp_seq 1633
Request timeout for icmp_seq 1634
ping: sendto: No route to host
Request timeout for icmp_seq 1635
ping: sendto: No route to host

It stays that way, with me having no internet access, until I unplug the ethernet cable. While this is going on I still have access to 172.17.30.x and 10.35.1.x. When I unplug the ethernet cable the ping to 10.35.1.1 starts timing out and the ping to 4.2.2.1 starts working again within a couple of seconds.

What causes this? How can I fix it? Would it be helpful if I include copies of my routing table at various points in the process? How do I get that?

Best Answer

You can adjust the order of your network interfaces in the Network panel of System Preferences. This allows you to set the primary adaptor for your network location, which in your case should be the Wi-Fi adaptor, since that provides the actual correct default route to the Internet.

The re-ordering UI is accessible by clicking on the 'gear' icon below the list of Network Adaptors on the left side of the Network Panel, and choosing "Set Service Order...".

You'll probably want to make & use a new Network Location for this setup, because in general (where either Ethernet or Wi-Fi provide valid default routes to the Internet), the Ethernet will be the better preference.

The same re-ordering can be useful for slightly unusual network setups, or VPNs where you may actually want all traffic to go through the VPN route (ie it should be the first service in the list) or maybe you only want the local subnet traffic on the VPN (ie your standard ethernet/wi-fi connections should precede it).