Monday, March 19, 2012

DNS with a DD-WRT Router

Setup Local/Internal DNS with a DD-WRT Router

I’ve talked about some features of the DD-WRT router before, and one of the things I’ve been playing around with lately is DNSMasq. There’s a good chance you haven’t noticed this setting in DD-WRT because it’s not something most people would ever think to use. Plus DNSMasq can be found in two different areas within DD-WRT since it can be used for both DHCP assignments as well as internal/local DNS management. What I will be focusing on is the local DNS aspect.

When is using DNSMasq useful for controlling DNS? Here are some examples as to why you may want to use it:

 

  • You have DNS pointing to something that is hosted on your home network and it is also accessible from outside your network. For example, you may have a security camera that has a domain attached to it (e.g. camera.example.com), and it’s accessed from both on and off your network. Using DNSMasq on your router you can make the domain, camera.example.com, point to the internal IP of the camera so that anyone who accesses that camera from within your network won’t have to rely on external DNS getting resolved. You should see at least a slight performance boost that way.

 

  • You want to override public DNS entries, such as google.com. You can obviously pull off some great pranks by directing traffic to sites like google.com or facebook.com to some custom site you create, but there are other reasons this is legitimately useful. Maybe you are testing a new version of your own website, but want to make sure it will work fine with the live domain. DNSMasq can help you accomplish that.

 

  • You want to create DNS for a site that is accessible using only a single word, such as intranet. Companies do this kind of thing all the time where an internal-only website can be reached without needing or wanting a publicly-accessible URL.

 

I know what you may be thinking… why wouldn’t you just update the HOSTS file on your local machine? Well, you could, but not all devices support that feature. By using DNSMasq the DNS change will work for anything connecting to your router, including mobile devices such as phones and tablets.

So what do you have to change in DD-WRT? Here’s what you need to do:

  1. Go to the Services tab once you’ve logged into the administration interface.
  2. Find the section labeled DNSMasq, and make sure the DNSMasq option is enabled.
  3. This is the fun part. In the Additional DNSMasq Options box type out your local DNS configurations in the format of one entry per line:
    • address=/machine_or_domain_name/ip_address – where machine_or_domain_name is what you want to create/change DNS for (e.g. camera.example.com, google.com, intranet) and ip_address is the new IP address you want it to point to.
  4. Apply the settings to DD-WRT, and you should be all set.

This is an example of what your DNSMasq settings may look like:

Ddwrt dnsmasq

If your devices don’t see the changes after they’ve been made you may need to try restarting them since that is often the simplest way to clear the DNS cache.

Taken From: http://cybernetnews.com/local-internal-dns-ddwrt/

No comments: