Disassociative Networking Disorder
April 8, 2008 10:27 AM   Subscribe

Is there a way for Leopard to bind a hosts file to a location in Network Preferences?

My workplace is on some weird network transition period where I can only check my mail when connected to the parent company's VPN. If I'm not connected to the VPN, I can use the office DNS just fine and contact all the servers in the office just fine. If I AM connected to the VPN, I can't use any of the regular office DNS and instead have to look up the name in an Excel spreadsheet and add it to my hosts file. Depending on whether I am on the VPN, the servers have different IP addresses, so the hosts file will only work on the VPN!

I've already created separate locations for being on and off the VPN in order to manage proxy settings, so I was wondering if there's any way to get something like the hosts file to stick to a particular location as well. This way I don't have to comment everything out of my /etc/hosts file when I get off the VPN.
posted by mkb to Computers & Internet (4 answers total) 1 user marked this as a favorite
 
Best answer: Try LocationX using an AppleScript plugin to update the host file when the location changes.
http://homepage.mac.com/locationmanager/index.html
posted by flif at 10:37 AM on April 8, 2008


Best answer: So what I've done in this situation is using "Search Domains". For each Location, add a different made up Search Domain to the list under the Network Adapter, Advanced, DNS. For example, under your VPN location, make it mydomain.vpn and under the other location, make it mydomain.other

Then in your hosts file, add servername.mydomain.vpn pointed to the IP address you use in the VPN and servername.mydomain.other pointed to the IP address you use the rest of the time.

Finally, wherever you use use the servername, just enter "servername" with no domain. Then when you are on your VPN, it'll automatically tack on mydomain.vpn and resolve to that IP address. When you are out and about, it'll tack on mydomain.other and resolve to that IP address.

This should work. If you have crappy DNS servers that some ISPs or the default settings of OpenDNS use, then servername will always resolve by itself, so it won't work, but this is worth a shot.
posted by AaRdVarK at 10:38 AM on April 8, 2008 [2 favorites]


Response by poster: Wow, thanks guys! I didn't hold much hope for an answer!
posted by mkb at 10:51 AM on April 8, 2008


For later comers to this thread: it seems like MarcoPolo is even better than LocationX, and it is even free!
posted by flif at 8:23 AM on April 17, 2008


« Older Where can I find cherimoyas?   |   Open Source Shopping Cart Newer »
This thread is closed to new comments.