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?
There 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.
Why not just add it to the adapter in question? i.e. ethernet or Wi-Fi: http://support.apple.com/kb/PH14159
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.
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