Squeeb
Squeeb

Reputation: 41

Two level domain suffix completion on a mac

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

Answers (3)

Dusan Jovanovic
Dusan Jovanovic

Reputation: 451

This doesn't work for El Capitan anymore. If you upgrade to El Capitan you need to do this:

  1. defaults write /Library/Preferences/com.apple.mDNSResponder.plist AlwaysAppendSearchDomains -bool true

  2. Reboot

See the mDNSResponder man page for more details.

Upvotes: 3

vincent
vincent

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

Viktor Gustavsson
Viktor Gustavsson

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

Related Questions