(Sorry if this question isn't worded well and/or is duplicate. I'm not a networking guy and I'm probably not using the right terms...this also makes it hard to see if this has already been answered.)

I'm running a CentOS server in VirtualBox, Windows host, and I can see access Apache-hosted pages at from machines on my LAN. But what I'd like is for people to be able to type http://hostname/ ...both because it's easier and primarily because I'm not sure that local IP is static. I'm not really sure how to proceed - could someone point me in the right direction? Thanks.


I assume you are using bridged networking (otherwise the VM wouldn't have been so easily accessible). Configuring the DNS for the LAN is up to whatever box controls it (some home router I expect).

If that router is too primitive and doesn't have its own DNS server, or you don't want to configure it, you could use mDNS. Install Avahi on Linux boxes, and Bonjour on Windows boxes.

  • I installed Avahi and we actually have some Macs in the office...advertising _smb and _http, I can see the fileshare in the Finder on OS X but hostname still doesn't work. :/ Edit: Oh, and yes, I'm using bridged networking. – rfrankel Jun 16 '10 at 18:46
  • Ah, I should have mentioned: the hosts are visible as http://hostname.local/. – Tobu Jun 16 '10 at 19:29
  • I forgot about Bonjour/ZeroConf. I love how well that works for situations like this. – Rob Moir Jun 16 '10 at 22:05

You could create a hosts file on Windows that points to as "webserver" or whatever name you like, so that Windows host will access it. This is assuming your Windows machine is also on 192.168.1.x, and the connection is bridged. Otherwise you could look at port forwarding your NAT'ed virtual network connection, but last time I tried it with virtualbox it was a bear to do, so I used bridged networking.

Otherwise you need to set up an internal DNS server with the proper records set for that IP. Overkill for what you're describing.

google hosts file windows to get info on how to set it up. Just a simple text file on your host Windows system, but will only work on that system, not for everyone in your network. If they're running Windows, you will need custom HOSTS files on their machines too. Cumbersome only if you have a lot of machines. If you're working in a larger site, you'll need to go with the DNS server route, which is only about three orders of magnitude more of a PITA to get initially set up unless you virtualize a DNS server :-)

  • Thanks...my ideal solution would involve something that scales and doesn't involve an extra server. Using zeroconfig/avahi/Bonjour seems to have done the trick, but I didn't want not to acknowledge your answer as well. :) – rfrankel Jun 16 '10 at 21:01

If your hosts have dynamic IP's, you need a DHCP server which either communicates with the DNS server, or which is a DNS server itself. I always use DNSMasq on my Linux-based routers, which do DHCP and name resolving.

If your router doesn't support nameserver, you can setup a nameserver, like bind, which knows which host is where. The downside of having a separate nameserver, though, is that you need to give your hosts static IP's and then give those IP's names in the nameserver.

As a last resort, you can also edit the hosts file on every client that needs to be able to lookup the server by name. I needs an entry like " bla.localdomain bla". The location of the host file is dependent on the OS.


If you're not sure that the IP address is static, then you probably want to see if/make sure that the web server has a DNS entry on the LAN, so that it can always be found. The problem with hosts files on the test clients is that they assume that the IP address IS static, so if the IP address changes then you'd have to keep updating the hosts file which is annoying.

The simplest answer would be to try and give the web server a static address (either by just assigning it a static address or getting a "DHCP reservation" configured), then you can just go with Bart's idea to use the hosts file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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