Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 127.0.0.1 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 192.168.1.1 as the secondary nameserver, but the concern here is that 192.168.1.1 will be using the Ubuntu box for DNS. Am I missing something obvious here?

  • dnsmasq settings: uncommented the following lines:

    domain-needed
    bogus-priv
    local=/local/
    domain=local
    
share|improve this question
    
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 '12 at 18:09
    
dnsmasq will work, but other alternatives include mDNS and NIS. –  Lèse majesté Apr 8 '12 at 19:51

1 Answer 1

up vote 2 down vote accepted

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.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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