Reputation: 41
In Ubuntu, I have this line present in /etc/resolv.conf
:
search example.com uk.example.com se.example.com
Now when I type host svr1.uk
I get the record for svr1.uk.example.com
If I ping svr1.uk
, I see pings from svr1.uk.example.com.
However, If I try to ping svr1.uk
on a mac with the same search
line present in /etc/resolv.conf I get "ping: cannot resolve svr1.uk: Unknown host"
although I do see the record for srv1.uk.example.com from the host
command.
Does any one have a way to make whichever lookup method ping
uses properly resolve the domain suffixes in the order presented in /etc/resolv.conf
?
Upvotes: 4
Views: 2173
Reputation: 451
This doesn't work for El Capitan anymore. If you upgrade to El Capitan you need to do this:
defaults write /Library/Preferences/com.apple.mDNSResponder.plist AlwaysAppendSearchDomains -bool true
Reboot
See the mDNSResponder man page for more details.
Upvotes: 3
Reputation: 1305
On OS X 10.7-8
Look for these lines (Around line 16; 10.8 starts around line 17), and add the third line on the end, then save the file
<string>/usr/sbin/mDNSResponder</string>
<string>-launchd</string>
<string>-AlwaysAppendSearchDomains</string>
On OS X 10.9
This is still around line 17 and will need to be re-edited after an OS upgrade. The "-launchd" line won't exist, so just append the alwaysappend
line.
Restart the responder:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
On OS X 10.10.1
The file is now called com.apple.discoveryd.plist
, and you need to add a very similar item below the ProgramArguments
tag. Add in <string>--AlwaysAppendSearchDomains</string>
(note, there are two hyphens) to the items in the tag. Run a similar pair of load/unload commands but referencing this new plist
Upvotes: 0
Reputation: 21
OSX does not use /etc/resolv.conf for DNS configuration. Instead check out networksetup.
To set the search domains:
sudo networksetup -setsearchdomains <network-interface> example.com uk.example.com se.example.com
To list the network interfaces/services:
networksetup -listallnetworkservices
Upvotes: 2