.local Domains on Ubuntu Desktop
at 7.43pmMy web development environment usually consists of an Ubuntu machine set up with a LAMP stack using Apache virtual hosts and a simple DNS setup. I tend to use a .local extension to the domains to make them easy to access and to compare to their online counterparts. For example I use oneangrydwarf.local for the testing environment for this site.
The problem comes when I set this up on an Ubuntu Desktop installation (as opposed to an Ubuntu Server installation) which I prefer simply for ease of use. Unfortunately a program called Avahi stands in my way by hijacking the top-level domain and overriding the DNS records. Apparently Avahi is used for “service discovery on a local network” and is an integral part of Ubuntu Desktop (attempting to remove it also removes the desktop environment) but personally I don’t need it and it gets in my way. For anybody else having this problem here’s how to fix it, firstly temporarily (if you need Avahi normally but just want a quick fix) and secondly a more permanent solution.
- Stop the Avahi daemon by typing
sudo /etc/init.d/avahi-daemon stop
This will only solve the problem until the server is rebooted as the process is integral to Ubuntu Desktop. Attempting to uninstall Avahi will also uninstall the Ubuntu Desktop.
- Tell Ubuntu to check the DNS server first by editing
/etc/nsswitch.confand changing the line that readshosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
to
hosts: files dns mdns4_minimal [NOTFOUND=return] mdns4
Now restart Avahi with the command
sudo /etc/init.d/avahi-daemon restart
See Avahi and dot-local addresses on Ubuntu Gutsy from The Fifth Wheel of andrewg for more details.
Nice tip… I might have a root around on my laptop for a similar fix, as OS X uses the same .local domain format by default which breaks most of the name resolution on my network (between my laptop and the rest of my network, that is). Now I’ve got my own Windows domain, though, things seem to have smoothed out a bit.