I want to set up MediaWiki on one of my home machines, and then have all requests made on the local network for 'wiki.home' or 'wiki.local' point to that box. I know that this can be done by editing each /etc/hosts file individually, but I want something more automated so that, for example, if a friend or family member comes to my house, they don't need to mess around with the hosts file in order to view the site.

Is there a simple way to do this? I have the wiki up and running, and I've been looking into dnsmasq, but I can't figure out how to set the DNS up properly. Since I want an automated solution, I feel like I need to change the DNS settings on my router, but if I change the DNS settings there, how can I still resolve external hosts?

Configuration Details

  • Router: Netgear WNR2000v2. The router gives me the option to manually specify DNS servers, which I'm assuming I will have to point to my Ubuntu box if I want to get this up and running.

  • MediaWiki and dnsmasq host: Runs Ubuntu 12.04. I've had some difficulty with the dnsmasq config (mostly due to my inexperience). For example, I'm not sure, but I think during installation, Ubuntu modified my DNS settings so that /etc/resolv.conf now had as the only DNS server. At that point, I could resolve the local hosts, but nothing else. I've solved this temporarily by modifying /etc/resolv.conf and adding as the secondary nameserver, but the concern here is that will be using the Ubuntu box for DNS. Am I missing something obvious here?

  • dnsmasq settings: uncommented the following lines:

  • Consider posting your configuration details. Also, what have you tried? What settings did you change on your router? What kind of router do you have? I assume your using linux, but what distro? There are so many things that could go wrong that we could write a book on the subject ;)
    – jmort253
    Apr 8, 2012 at 18:09
  • dnsmasq will work, but other alternatives include mDNS and NIS. Apr 8, 2012 at 19:51
  • can you just change the name of your machine on the wifi?
    – rassa45
    Feb 7, 2016 at 4:02
  • Can somm\eone clarify, will avahi/bonjour ALWAYS use the .local? Then there is a question of the trailing "." , like ".local." which I believe is to restrict the method of name resolution, but when should it be used instead of just ".local"? Apr 7, 2022 at 16:50

3 Answers 3


With standard DNS, you would run a DNS server that is authoritative for the local domain you choose (like the typical .home or .lan or the "standard" .home.arpa) in addition to acting as a "normal" resolver for everything else.

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

# cp /etc/resolv.conf /etc/dnsmasq-resolv.conf
# echo "nameserver" > /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).


Local name resolution is a simple feature and it's been part of most routers that I used. It's also implemented in DD-WRT firmware. Netgear doesn't care for this feature that is constantly requested.

So, the answer that is much simpler than the others posted here - avoid the trouble and change your Netgerat router to something that supports local name resolution. Or, if that's not an option, and you feel the strength and got the time, flash DD-WRT on it.


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.