Fixing OSX Lion DNS Search Domains
One unexpected consequence of upgrading to Lion is that suddenly my normal DNS search domains stopped working. We use multiple VLANs at work with their own DNS sub-domains based on the environment.
For example, we might have a www01.staging.internal.lan and a www01.prod.internal.lan. When using any command line tools like SSH, its normal to just use the host+environment to address them:
ssh erik@www01.staging
This is a very common seetup for corporate lans and our internal DHCP publishes the internal.lan part as a DNS search domain. Everything worked as expected until I upgrade to 10.7. Now any hosts lookups that have a “.” in them do not use the search domains.
After some searching for possible solutions, I ran across a thread here and another blog post here that described the same issue.
Here’s how to change the DNS lookup behavior to work as expected:
- Make a backup of /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
sudo cp /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist ~/com.apple.mDNSResponder.plist.original
- Edit com.apple.mDNSResponder.plist — its a plain text file, so I used vim but you can use whatever text editor you have handy. Don’t forget to use sudo.
sudo vim /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
- Add <string>-AlwaysAppendSearchDomains</string>after line 16
<key>ProgramArguments</key> <array> <string>/usr/sbin/mDNSResponder</string> <string>-launchd</string> <string>-AlwaysAppendSearchDomains</string> </array> - Now unload and reload the mDNSResponder service:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
Thats it — you should be able to perform DNS lookups the same way as always.
Pingback: Fix for broken search domain resolution in OSX Lion | Making It Scale