How can I set up a 'local' domain so that everyone on my local network can view a locally hosted site?

With standard DNS, you would run a DNS server that is authoritative for the local domain (home. or local., although it's better to avoid the latter – see note below), but also acts as a resolver for all other domains.

dnsmasq can be used for this purpose – it has recursive mode enabled by default and your configuration looks fine; all that's needed is to tell it which nameservers to use for non-local domains. Normally those would be read from system's /etc/resolv.conf file; however, since you want the local domain to work on the DNS server computer too, you will need to create a dedicated copy of resolv.conf which would be used only by dnsmasq, while the original resolv.conf would point to nameserver 127.0.0.1.

# cp /etc/resolv.conf /etc/dnsmasq-resolv.conf
# echo "nameserver 127.0.0.1" > /etc/resolv.conf
# dnsmasq -r /etc/dnsmasq-resolv.conf

Note: These instructions are very basic, and should be adapted to the Linux distro in use. In particular, check the Debian and Ubuntu guides on dnsmasq.

After this, the router needs to be configured to use this computer as the DNS server; all DNS queries by computers in your network would then be handled by dnsmasq.

(Full-featured DNS servers, such as bind9, can perform recursive queries themselves – configuring upstream nameservers becomes entirely optional. This is how your ISP's nameservers work, for example. However, hosting your own domain with bind9 is fairly complicated at first, in comparison with the simple dnsmasq.)


Note: If you have Avahi (aka Bonjour) configured on any computer in the network (which Ubuntu has, by default), it's best if you avoid local. in DNS and choose something like home. instead, as names in the form of name.local are already handled by Avahi.

(Although Avahi normally only responds to current-hostname.local, it is actually possible to publish additional entries such as wiki.local; they will, however, need additional IP addresses to be added due to the way mDNS works. Because of this, using Avahi instead of centralized DNS does not offer any more advantages, so I'm not suggesting it.)


I found the Avahi daemon to be the easiest way to do this. Note: if you are using Windows machines to connect to the .local domain, you need to make sure those machines have either iTunes or another Bonjour client installed on them.

Check out this link for more info: http://www.howtogeek.com/167190/how-and-why-to-assign-the-.local-domain-to-your-raspberry-pi/

Although that link is specific to the Raspberry Pi, it should work on Ubuntu machines the same way. For other Linux distros that don't use apt-get, just adjust apt-get to your appropriate package manager - e.g. yum for Fedora and CentOS)

Here are the exact commands I ran to get this going on my Raspberry Pi media server:

sudo apt-get update && sudo apt-get upgrade sudo apt-get install avahi-daemon

From there it automatically begins using your computer's hostname plus the .local extension as it's domain name. So if your machine's hostname is mediaserver, then you can access it on the network by typing mediaserver.local into the URL bar of any machine that has Bonjour/Avahi on it (i.e. all Macs, plus Windows machines with iTunes installed).