Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I run a web server locally on my Mac. I use Virtualbox to run various Windows guest OSes thanks to The server on my host machine is running WordPress in a multi-site set-up and requires a host name in the request to serve up the correct site. IP address URLs won't work.

The Virtualbox network adapter is in NAT mode and I found the IP address of my host machine. I can get everything to work by editing the hosts file in the Windows guest OS. The entry looks something like this:

Then in Windows if I browse to everything works as it should.

So my question is... Can I set it up so I don't need to edit the hosts file of my guest OS everytime the IP address of my host machine changes? Something like a reverse port forward so I could set a hosts file entry like so...

and Virtualbox would listen for a request to and change it to ?

share|improve this question

closed as off topic by Michael Hampton, mgorven, Scott Pack, Dave M, mdpc Feb 5 '13 at 2:48

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

It turns out this is dead simple. I just needed to edit the Windows hosts file pointing

Something about being the default gateway for NAT connections? I gleamed the solution from this answer ->

share|improve this answer

Your solution works but I'm rather surprised that it does, seems like it would cause problems if you happened to use 10.0.2/24 in your network somewhere. The alternative is to change your VirtualBox guests' network modes to Bridged, randomize their MAC addresses (if they're not already unique), and get them their own IPs on the network. At that point, they may live on your machine but they'll act just like someone else's PC in the office next door, so they provide more authentic test setups.

share|improve this answer

The sledgehammer approach would be to stand up a dns server that listens and serves dns information on the virtualbox only network (I'd recommend dnsmasq through homebrew.) That ultimately depends on how handy you are with DNS, or how much time you're willing to invest in figuring it out. I'd be happy to elaborate if there's any interest.

share|improve this answer
I tried figuring out how to set-up a DNS server on my local machine so I could test code served from my local machine to my phone. I think I looked at dnsmasq but couldn't get it to work. – kingkool68 Feb 5 '13 at 20:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.