How do I manage my HOSTS/LMHOSTS file and/or better manage a virtual machine IP that changes?
June 5, 2008 8:50 AM
Subscribe
How do I manage my HOSTS/LMHOSTS file and/or better manage a virtual machine IP that changes?
I'm on a Windows XP machine. I have a linux virtual machine (Centos 5) running in VMWare Workstation.
I'm doing some web development on this virtual machine and I use the hosts file to make some dummy entries like:
192.168.1.4 www.domainnamestaging.com
192.168.1.4 domainnamestaging.com
192.168.1.4 www.anothersiteimworkingon.com
192.168.1.4 anothersiteimworkingon.com
and in the lmhosts something like
192.168.1.4 linux
Then I'll make a SMB share to \\linux\whatever and I can test my website with http://www.domainnamestaging.com/ and that all works fine. The VMWare networking is set to Bridged networking which just treats the Virtual Machine as if it's on my router like any other machine.
The only problem with this is sometimes I'm working at a coffee shop with no connectivity in which case I have to change the Virtual Machine's networking to a "private network" where the IP changes to something like 192.168.199.128 and I have to go through the HOSTS and LMHOSTS file and change all those entries to the new IP address. Or the coffee shop will have internet access but their router gives me a completely different IP address for the Virtual Machine.
I'm thinking I could write a script to search and replace all the IP addresses in those two files, but I'm guessing there has to be a better way? Is there some program/networking trick that switches all this stuff easily, bonus points if I don't have to run anything, it just works regardless of how it's connected?
posted by bertrandom to computers & internet (7 comments total)
posted by meta_eli at 9:15 AM on June 5