MacOS – Local DNS circumvented when WiFi is active

dnsmacosNetworkwifi

I am using Mac OS X 10.8 to connect to two networks through ethernet and wifi and I am experiencing a problem with local DNS resolution. I would really appreciate your advice.

I am simultaneously connected to two networks. A local network through ethernet (eth) and to the internet through my company's wireless AP (wifi). I would like to be able to query by name my local computers (like ping computer1) but also I would like to have internet connection through wifi.

In the Network Preferences I have the following priority:
First ethernet and then wifi.

By doing so, it works correctly when I ping local computers by IP. i.e. ping 192.168.1.1 works and I can access the internet as well. DNS settings for each interface are listed correctly in the Network Preferences settings. i.e. DNS for eth is 192.168.1.1 and search domain mydomain.com. For the wifi, DNS are also listed correctly with the settings my company provides.

If I disable wifi, local DNS works fine, when using ping computer1 or nslookup computer1. However, when wifi is enabled, I do not succeed in resolving names with the local DNS server. I have found that the resolv.conf file is overwritten when I enable wifi and therefore local DNS server is not contacted, instead my company's DNS is contacted. To be more specific, when wifi is enabled, the resolv.conf file holds only DNS information provided by my company (even though I prioritised it second position in Network Preferences ):

So when WiFi is enable, resolv.conf has the following:
domain my.work.domain.com
nameserver x.x.x.x
nameserver y.y.y.y
nameserver z.z.z.z

When WiFi is disabled, resolv.conf has the following:
domain mydomain.com.
nameserver 192.168.1.1

Similar issues appears when using scutil –dns.

When I have BOTH eth and wifi enabled, using scutil –dns, I get the following:
DNS configuration

resolver #1
search domain[0] : my.work.domain.com
nameserver[0] : x.x.x.x
nameserver[1] : y.y.y.y
nameserver[2] : z.z.z.z
if_index : 4 (en0)
reach : Reachable

(Here are listed but removed by me the rest of DNS resolvers #2 – #7 that normally Mac users have for internet )

DNS configuration (for scoped queries)

resolver #1
search domain[0] : mydomain.com
nameserver[0] : 192.168.1.1
if_index : 6 (en2)
flags : Scoped
reach : Reachable,Directly Reachable Address

resolver #2
search domain[0] : my.work.domain.com
nameserver[0] : x.x.x.x
nameserver[1] : y.y.y.y
nameserver[2] : z.z.z.z
if_index : 4 (en0)
flags : Scoped
reach : Reachable

When I disable WiFi and only keep ethernet, using scutil –dns, I get the following:
DNS configuration

resolver #1
search domain[0] : mydomain.com
nameserver[0] : 192.168.1.1
if_index : 6 (en2)
reach : Reachable,Directly Reachable Address

(Here are the same as above resolvers #2 – #7 that normally Mac users have for internet )

DNS configuration (for scoped queries)

resolver #1
search domain[0] : mydomain.com
nameserver[0] : 192.168.1.1
if_index : 6 (en2)
flags : Scoped
reach : Reachable,Directly Reachable Address

Thank you very much for the time you spend for my problem. Kind regards !

Best Answer

I think the DNS settings for each device are independent, so you need to configure DNS in the Advanced tab of system preferences for each NIC (en0, en1, etc.)