• ARTICLES
SEARCH

How-To Geek

How To Access Your Machines Using DNS Names with DD-WRT

We’ve shown you how to statically set the IPs on your network, now lets flip that DNS switch for added elegance and ease of use. Today’s guide will show you how to access your machines using DNS names on your DD-WRT enabled router.

Image by Henk L

Preface

On our How To Set Up Static DHCP on Your DD-WRT Router guide, we’ve talked about making sure that your clients will always get the same IP address from the router. So now if you want to access one of the machines on your network, as you know it’s IP, you can use that… but using IPs just doesn’t have the same elegance as using names. Also, with the usefulness of “static IP”s dwindling due to the rise of UPnP, and the inconvenience of setting up “static reservations“ (having to find the MACs and alike)… What if you don’t want to remember IPs at all?
That is where DNS comes in.

The Problem

You’re trying to reach from one machine/device on your network to the other using its IP address (using ping for example) and it works. However, when trying to do the same using it’s hostname like “mydesktop” or “mylaptop”? it is a hit and miss… sometimes it works…. usually it doesn’t… :\

What is going on?

Your devices don’t know who and how they should ask for the “name” to “IP” translation, because they are missing a key configuration, the “DNS suffix”.

When a computer needs to translate a name to an IP address (called “resolve”) it has a couple of ways to do it, one of the ways is to ask a Domain Naming System (DNS) server. However, to be able to do so, the client must ask the question in the form of a “Fully Qualified Domain Name” (FQDN).

An FQDN consists of the hostname like “mydesktop” and the DNS zone it belongs to like “geek.lan”. So in our example, the FQDNs for the hosts would be “mydesktop.geek.lan” and ”mylaptop.geek.lan” respectively. When a client doesn’t have the “DNS zone” at hand, it is unable to ask the DNS about a  “flat” name (a name that doesn’t specify the “DNS zone”). That is, to actually reach your host by name, you would need to ping “mydesktop.geek.lan”.
However, if the DNS suffix was defined in some way (either manually or automatically), the client will automatically try to append it to the requested hostname and ask a DNS server if it can help with the resolve.
With that said, if the DNS suffix is not defined, the client does try to find out the name on its own, using a “DNS broadcast”. The problem with that is that not all clients are configured to answer, or are actually configured to deliberately not answer such a request. In contrast, it would simply be annoying to specify the FQDN every single time.

The solution

In order to have the full infrastructure that will fix this problem, one only needs to set the “DNS suffix” on the “DHCP scope” of the *router. Doing so will both make it so the router will now have a “dynamic DNS” server service that clients can register themselves to, make it so the DHCP service it self will do the same for none-self-registering hosts and deliver the “DNS suffix” as part of the “DHCP lease” given to the clients. Therefore making the entire solution a self sustaining, default behaving solution that solves all the problems in one fail swoop…. neat, A?

*When using DD-WRT… with other routers, your mileage may vary.

To do this, go into your router’s Administration page:

dhcp suffix1

  1. Go into –>  Services
  2. Change, “Used Domain” to be “LAN & WLAN”
  3. Choose a Domain name, we’ve used “geek.lan” for this example, but you can use *whatever you want.
  4. While using Static DHCP reservations is optional for this procedure, if you chose to implement it, it is recommended that you set the hostname, to match the one that is set on the machine/device’s OS. Now if it just so happens that the devices OS, doesn’t register a name in DNS (like phones) this is a good way to force one on it.
  5. Click “Save” –> “Apply Settings”.

*The one exception to that rule, is that if you use “.local”, while your windows machines will probably do just fine, your Linux machines will adhere to the mDNS (Multicast DNS) standard and will again ignore the DNS server. There is a workaround, but it’s beyond the scope of this guide.

Now to check that the settings have taken affect, go to the command line and issue an “ipconfig”.

You should see that your DNS suffix is currently none-existing as below:

dhcp suffix2

Issue an “ipconfig /release” followed by an “ipconfig /renew”, and you should see something like:

dhcp suffix3

Repeat the procedure on at least one more machine and try pinging, using only the hostname name.

You should see that the client has “auto-magically” understood that the full name of the device you’re pinging is “hostname.dns.zone”, and was able to translate (resolve) the FQDN to a ping-able IP:

dhcp suffix4

Troubleshooting

As this guide is about using DNS like the How to Remove Advertisements with Pixelserv on DD-WRT guide was, If you run into problems there are a couple of things to do:

  • Clear your personal machines DNS cache.
    This is because of a DNS cache, that may fool your computer into thinking it already knows the hostname, without consulting the DNS for it. On windows this would be “ipconfig /flushdns”.
  • Make sure your client is using the router as the DNS and that it resolves the FQDN.
    Especially when using a VPN or a network that is more complex then the normal router to computer setup, it is possible that your client computer is simply not using the router as its DNS. It is very easy to see using the command “nslookup” below what is the DNS server the client is using. If the IP is not the same as the router, you have found the problem.
    dhcp suffix5

That’s it… you should be all set Smile


Hurry, all I see is darkness.

Aviad Raviv, is an agile IT implementer that has reached the level of "Bankai" and is now working on incorporating the "hollow" side. https://www.facebook.com/Hotfortech

  • Published 08/22/11

Comments (7)

  1. tehsnarf

    Now, the question becomes, how do I access my hosted webpage on my ubuntu server within my LAN? I would really like to go to http://www.xyz.com and have it show up the correct page, as right now I have to use the internal IP address. Any thoughts or suggestions?

    (By the way, I used article, and it worked flawlessly. Thanks!)

  2. Sean

    I just use BIND on a NetBSD machine for this, for security reasons the DNS resolver is a separate machine then the gateway.

  3. Screwtape

    Does Tomato support this feature?

  4. alexd

    What about port forwarding? Is there a way to forward a port without using static DHCP reservations?

  5. Aviad

    @Screwtape
    I haven’t been in Tomato for a while, with that said, i think I’ve seen that Tomato uses the same service for DHCP… so you should be able to do this… you may have to set it up manually though.

    @alexd
    you don’t have to use static reservations, but it is recommended… because it ensures that the machine your forwarding the ports too hasn’t left the IP for another, unsuspecting, machine.

    with that said, i’d seriously look into using UPnP. all you have to do to use it, is turn the feature on in the router (a simple radio button in the NAT/QoS section… and i even think it is on by default) and use a UPnP compatible application… presto… all the required ports are opened automatically and you never have to forward ports again.

  6. Two Replies

    Be careful about using short domain names, because if you use your domain and are externally hosting a site with wildcards enabled then attempts to browse to that machine from the local network will hit a local network machine instead of the wildcard-enabled external site.
    So if you own your own domain, tack on a local identifier like LAN Domain= LOCAL.howtogeek.com
    That way if you happen to change the assigned hostname of one to be “www”, it won’t hijack http://www.howtogeek.com requests.

    Also, you should put “expand-hosts” into the DNSMasq other options.

  7. Aviad

    @Two Replies

    While the expand-hosts looks useful, i have been using the setup described for the past 5 years, and have never found it necessary. your other tip is spot on, thanks.

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!