nslookup works with /etc/resolv.conf, ping and ssh don't 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.
I had the same problem.  The solution I used was to create an /etc/resolver directory.  Inside that directory, create a file named for each domain you wish to resolve for.  Inside each file there should be two lines

nameserver 10.0.100.2
domain  home.cainmanor.com


The file above would be named /etc/resolver/home.  It may need to be named home.cainmanor.com, but I can't test it right now.

Good luck!