Fix for broken search domain resolution in OS X Yosemite

Ok folks, after many moons trying to fix this issue in Yosemite I finally got it… If you are running earlier versions of OSX, see here for the fix.

What am I talking about?

Append search domains for partially qualified domain names when performing DNS lookups. You know.. For example, you work in it and ssh to hosts regularly and your company uses hostname.sub.domain.com or hostname.domain.com but you want to ssh to hostname or hostname.sub to shave some time off your clock. With older versions you could apply a fix with mDNSResponder to work around whatever Apple decided to do there; around rolls Yosemite and they change the whole damn thing around.

The fix?

NOTE: You must have the OS X Yosemite v10.10.1 Update installed prior to doing this.

Open up /System/Library/LaunchDaemons/com.apple.discoveryd.plist (I do this from command line)

Open Terminal and type in the following:

sudo vi /System/Library/LaunchDaemons/com.apple.discoveryd.plist

In the ProgramArguments block add the following parameter to the list:

<string>--AlwaysAppendSearchDomains</string>

So that section of your file should look like this:

        <key>ProgramArguments</key>
        <array>
                <string>/usr/libexec/discoveryd</string>
                <string>--udsocket</string>
                <string>standard</string>
                <string>--loglevel</string>
                <string>Basic</string>
                <string>--logclass</string>
                <string>Everything</string>
                <string>--logto</string>
                <string>asl</string>
                <string>--AlwaysAppendSearchDomains</string>
        </array>

Then restart com.apple.discoveryd.plist with:

sudo launchctl unload /System/Library/LaunchDaemons/com.apple.discoveryd.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.discoveryd.plist

And just in case

Should things go wrong, here is the original file in full:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.apple.networking.discoveryd</string>
        <key>UserName</key>
        <string>_mdnsresponder</string>
        <key>GroupName</key>
        <string>_mdnsresponder</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/libexec/discoveryd</string>
                <string>--udsocket</string>
                <string>standard</string>
                <string>--loglevel</string>
                <string>Basic</string>
                <string>--logclass</string>
                <string>Everything</string>
                <string>--logto</string>
                <string>asl</string>
        </array>
        <key>EnableTransactions</key>
        <true/>
        <key>KeepAlive</key>
        <true/>
        <key>InitGroups</key>
        <false/>
        <key>WaitForDebugger</key>
        <false/>
        <key>MachServices</key>
        <dict>
                <key>com.apple.discoveryd.dnsproxy</key>
                <true/>
                <key>com.apple.discoveryd</key>
                <true/>
                <key>com.apple.d2d.ipc</key>
            <dict>
                <key>ResetAtClose</key>
                <true/>
            </dict>
        </dict>
        <key>Sockets</key>
        <dict>
                <key>ServiceDiscovery</key>
                <dict>
                        <key>SockFamily</key>
                        <string>Unix</string>
                        <key>SockPathName</key>
                        <string>/var/run/mDNSResponder</string>
                        <key>SockPathMode</key>
                        <integer>438</integer>
                </dict>
        </dict>
        <key>BeginTransactionAtShutdown</key>
        <true/>
        <key>POSIXSpawnType</key>
        <string>Interactive</string>
        <key>EnvironmentVariables</key>
        <dict>
        <key>USE_DEFAULT_COMPUTERNAME_WITHOUT_MODEL</key>
        <string>1</string>
                <!--Uncomment these keys to enable malloc debugging-->
                <!--<key>MallocGuardEdges</key>-->
                <!--<string>1</string>-->
                <!--<key>MallocStackLogging</key>-->
                <!--<string>1</string>-->
                <!--<key>MallocScribble</key>-->
                <!--<string>1</string>-->
                <!--<key>MallocCheckHeapStart</key>-->
                <!--<string>1</string>-->
                <!--<key>MallocCheckHeapEach</key>-->
                <!--<string>500</string>-->
                <!--<key>MallocCheckHeapAbort</key>-->
                <!--<string>1</string>-->
                <!--<key>MallocErrorAbort</key>-->
                <!--<string>1</string>-->
        </dict>
</dict>
</plist>
Advertisements

12 thoughts on “Fix for broken search domain resolution in OS X Yosemite”

  1. You can do this with a single line Terminal command:

    sudo defaults write /System/Library/LaunchDaemons/com.apple.discoveryd.plist ProgramArguments -array-add “–AlwaysAppendSearchDomains”

    That should all be on a single line. Then do the same unload/reload as advertised above.

    Like

  2. Actually Matt, I tried that on my test machine and it messed up the file.. Left it all crazy like…. Here is a small output from it after the command you outlined:

    bplist00Ý^A^B^C^D^E^F^G^H
    ^K^L^M^N^O^R^S^N^R^S^V^W"+^R-YGroupName_^P^TEnvironmentVariablesYKeepAlive_^P^OWaitForDebuggerXUserName_^P^REnableTransactionsZInitGroupsULabel_^P^P

    Like

      1. I’m running 10.10.2 (Yosemite) fully patched. Trying to access hosts within a few subdomains, e.g. *.a.foo.com, *.b.foo.com. One curve ball though is going through VPN client. I think that may be interfering, but I’m not sure how to dig deeper to figure out what component in this system is preventing search path expansion. Any ideas? Thanks.

        Like

        1. VPN should not hamper it. Can you ping a *.a host?

          In Terminal, run this command, does the ProgramArguments section contain the needed line?

          cat /System/Library/LaunchDaemons/com.apple.discoveryd.plist

          If not try running the editing it with sudo:

          sudo vi /System/Library/LaunchDaemons/com.apple.discoveryd.plist

          I’m taking it you’re trying to ssh or other accessing via Terminal to those hosts?

          Like

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s