How can browsers in VMs resolve hostnames of websites on parent PC?

2

1

I have a number of local websites in development on my Windows PC, set up as virtual hosts within Apache, with hostnames (along the lines of dev.example.com) resolved via the hosts file, so I can test them out them with various browsers.

I now want to extend browser testing to running browsers in various OSs in virtual machines, and want to be able to resolve dev.example.com from the VMs. Currently these are a mix of VMWare Server and VirtualPC.

I know I can edit the hosts file on any Windows VMs, but this is a bit fiddly and I'd like a solution which is independent of the individual VMs.

I think what I need is a nameserver, but what's the simplest way of going about this? I'd like everything to be self-contained on the one machine.

I think I can cover firewall and Apache permissioning issues.

e100

Posted 2010-03-10T14:30:02.023

Reputation: 1 078

You either have to change the hosts file or the DNS server (in network settings) on the VM. I mean to say: both are editing something. (or something+alot) – Rudie – 2011-04-05T22:23:27.420

Answers

2

Host files are by far the easiest method to do what you want.

If you do not want to use them, then take a look at creating another Virtual Machine and installing either Linux with a DNS server (I can't really recommend any distributions over any others), or Windows Server 2003 (or 2008).

In Windows 2003/2008, you can install DHCP Server and DNS Server, create a new zone for each of the domains you want - and put the IP of your main machine. (In Linux, you can obviously do the same, but I can't really recommend much - in the past, I have used Ubuntu Server + Webmin to do the hard work, if you are good at Linux, you may find it easy - but I find using Windows Server to be much simpler for this.)

All you need to do from the client machines is set to automatic IP and make sure that the DHCP server is the only one accessible, or skip DHCP and just set the DNS server to the IP of the virtual machine. If you also set forwarders (or just use Root Hints) on the DNS server, it should be able to fully resolve all sites on the internet as well as serving the sites you want.

There is so much I can say on this, I almost didn't write an answer because I didn't think I would touch all the points I need to - if you want clarification or more information on any points, feel free to ask.

William Hilsum

Posted 2010-03-10T14:30:02.023

Reputation: 111 572

Many thanks for this. It does seem a bit more work than I had anticipated. I think I will probably use host files for now and investigate the options you have suggested at a later time. – e100 – 2010-03-11T08:40:58.290

1

On my home network, I have a Windows XP host with a VirtualBox FreeBSD guest, with a bridged network interface.

I have a router running Tomato firmware. Every machine on the network--real or virtual--gets a static DHCP entry that includes its hostname. I set the "Use Internal Caching DNS Forwarder" option in Tomato, and the result is that every DHCP client uses the Tomato router as its DNS server, and the router correctly answers requests with the static DHCP hostnames.

coneslayer

Posted 2010-03-10T14:30:02.023

Reputation: 7 494

Thanks but I'd like it all running on the one PC - a laptop - so I'm not tied to a single location. – e100 – 2010-04-12T20:27:47.283