resolv.conf search domain not working on OS X

I use network setup to modify my search domains which works fine so far, but it only does it per device. Once I VPN somewhere, it no longer uses those changes. Is there a way to set the search domains globally (ie. for every device: Ethernet, Wi-Fi, and VPN) on Mac OS X Lion?


Solution 1:

enter image description hereThere was a similar issue in 2002 with OS X. I found a few articles about it and I've been able to address this issue by simply adding "local" to the Search Domains in the advanced network properties of my network interface. This has allowed those of connecting via VPN to resolve .local hosts.

Solution 2:

If you want a strict command line solution, you can add the search domains manually to each adapter/service.

  1. List all networkservices to get the common names:

    $ networksetup -listallnetworkservices
    Wi-Fi
    FT232R USB UART
    Thunderbolt Bridge
    Thunderbolt Ethernet
    
  2. Check the current searchdomain setting on the device you want to update (You must fully quote devices with spaces in the names):

    $ networksetup -getsearchdomains "Thunderbolt Ethernet"
    yourdomain.com
    yourdomain.lan
    
  3. Then add the searchdomains you want where they are missing:

    $ networksetup -setsearchdomains "Wi-Fi" yourdomain.com yourdomain.lan
    

Solution 3:

Why not just add it to the adapter in question? i.e. ethernet or Wi-Fi: http://support.apple.com/kb/PH14159 Per: https://web.archive.org/web/20150227052942/http://support.apple.com/kb/PH14159


For example, if you specify the search domain apple.com, typing “store” in your web browser takes you to store.apple.com. Or, if you use campus.university.edu as a search domain, you can type “server1” in the Connect To Server dialog in the Finder to connect to server1.campus.university.edu.

Choose Apple menu > System Preferences, then click Network.
Select the network connection service you want to use (such as Wi-Fi or Ethernet, unless you named it something else) in the list, then click Advanced.
Click DNS, then click Add (+) at the bottom of the DNS Servers list. Enter the IPv4 or IPv6 address for the DNS server.
Click Add (+) at the bottom of the Search Domain list and enter the search domain, for example, apple.com.

When you’re finished, click OK.
Domains are searched in the order you list them, and the search stops when a valid name is found.

To search a name hierarchy, use search domains of varying scope. For example: building.campus.university.edu, campus.university.edu, and university.edu.

com.apple.mDNSResponder.plist can be overwritten by something else/update and you will forget it. The url above is the "supported" way to add the domain search path to the DNS query.