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?
If you want a strict command line solution, you can add the search domains manually to each adapter/service.
List all networkservices to get the common names:
$ networksetup -listallnetworkservices Wi-Fi FT232R USB UART Thunderbolt Bridge Thunderbolt Ethernet
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
Then add the searchdomains you want where they are missing:
$ networksetup -setsearchdomains "Wi-Fi" yourdomain.com yourdomain.lan
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.