I just want to have a local server inside my VirtualBox that offers DNS functionality like www.example.local => 127.0.0.1. My host operating system is Ubuntu 11.10 and guest is Ubuntu 10.10.

On my server I can already ping www.example.local - so I configured my virtual host correctly.

Question is, how can I address www.example.local from outside my VirtualBox? I searched Google and AskUbuntu and found dnsmasq.
I installed dnsmasq on my server and followed all steps on help.ubuntu. On my host system I've set 192.168.178.91 to the list of DNS servers (192.168.178.91 is the IP address of my local server which uses a bridged network adapter).

2 Answers
2

If hostname.local on your local network is the goal, then you don't need to do anything. You can just connect to it. If your laptop is named mylaptop, for instance, just connect to mylaptop.local. It's done using Avahi out of the box.

So… my Apache server is on my VirtualBox guest at 192.168.178.91. I want to type localhost or myproject.com in my browser on my host system (and on other devices in my lan) to reach the server. You mean avahi can already handle such requests?
–
Boris Karl SchleinFeb 23 '12 at 20:28

If Ubuntu by default makes hostname.local available to all other clients on the local network, I see no reason why ".local" shouldn't be changeable to something else. I've never done it myself. But yes, you can connect to computers on your local network using hostname.local.
–
Jo-Erlend SchinstadFeb 24 '12 at 0:52

On the host, you probably have the dns server set in /etc/resolv.conf to a different machine (like your router or your isp DNS). You can change it to your virtual server after running it but since the virtual server will be loaded after the host obviously, if you make the change permanent, you won't have DNS before loading the virtual server and this can be a problem. On other machines, you can make this change permanent.

Anyways, before changing anything, you could just test if the DNS server is working well by issuing on the host machine:

tbh I don't know why you need dnsmasq. Maybe I didn't understood something in your config but I would use only bind on the guest and your usual dhcp server to send the required IP to the guest (or fixed IP). Can you ping the guest from the host by IP? If yes, I think bind is not working (or the firewall is blocking).
–
laurentFeb 23 '12 at 15:46

Hum, I haven't installed bind at all. I thought dnsmasq is doing its job. But yes, I can ping my guest. So I will try bind later. Thx so far. :)
–
Boris Karl SchleinFeb 23 '12 at 16:06

Not sure on that but I think dnsmasq only forward public DNS and serves the local machines names its DHCP server has registered, not other domain names (even if they are from the local domain names)
–
laurentFeb 23 '12 at 16:19

Ok, I am trying bind9 right now but all I got is a servfail by digging. I found this tutorial and followed its steps.
–
Boris Karl SchleinFeb 23 '12 at 20:30