MacOS – nslookup works with /etc/resolv.conf, ping and ssh don’t

macosNetwork

In our local university network, I have (obtained by DHCP) the following setup in /etc/resolv.conf:

search a.domain.com b.domain.com domain.com
nameserver x.x.x.x
nameserver y.y.y.y

The settings are the same in System Preferences as well.
The following problem occurs:

nslookup server

works, and is using one of the nameservers to correctly ask for server.a.domain.com.
If I try to ping however,

ping server

fails with unreachable host.

ping server.a.domain.com

works. Manually adding server with the ip address obtained by nslookup to /etc/hosts makes ping work too, but this "solution" circumvents the nameservers and is thus not ideal (and I would have to add about 20 other entries as well). Any idea what is causing this? Why does ping not use the results of nslookup/the searchdomains?

ssh server

also fails, which is the real problem/inconvenience.

I already added AlwaysUseSearchDomains to mDNSResponder, but this fix only helps the problem when using server.foo.

I'm using OS X Lion 10.7.3.

Best Answer

Well, did you read the comments at the top of /etc/resolv.conf?

# Mac OS X Notice
#
# This file is not used by the host name and address resolution
# or the DNS query routing mechanisms used by most processes on
# this Mac OS X system.

The correct solution is to add the search domains via the Network panel in System Preferences as described here.