Wednesday, January 19, 2011

Simple DNS solution for VM-based server

I run a Ubuntu server in a VM with VirtualBox on my Windows host machine. The Ubuntu hosts the webserver and is used for PHP development. However, I'm trying to figure out the easiest way to setup the DNS. I used to use the Windows Hosts file to forward domains to my localhost when I ran the webserver on the same OS. However, the VM is running bridged mode and so can have a different IP address depending on my current network. I could setup the VM to use a static IP address, but was wondering if there are any other solutions or ideas how to best tackle this software. One idea I had was to setup a BIND DNS Server on the VM but that requires hardcoding the forwarding DNS server, not an option in my case.

  • Assuming that you are using DHCP to obtain your IP address for the VM and depending on how the DHCP server is set up, you can send a hostname information to your DHCP server. If the DHCP server has been set up to update the DNS entries, the machine can be readily identified by this hostname.

    There is a send host-name "<hostname>"; option in /etc/dhcp3/dhclient.conf.

    From sybreon
  • use a static IP address on the server or set up your DHCP (router) to supply a static IP address and then use the hosts file. Its by far the simplest way.

0 comments:

Post a Comment