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
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.
Your 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.
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:
- Go into –> Services
- Change, “Used Domain” to be “LAN & WLAN”
- Choose a Domain name, we’ve used “geek.lan” for this example, but you can use *whatever you want.
- 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.
- 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:
Issue an “ipconfig /release” followed by an “ipconfig /renew”, and you should see something like:
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:
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.
That’s it… you should be all set
Hurry, all I see is darkness.
Monday, August 22, 2011
How To Access Your Machines Using DNS Names with DD-WRT - How-To Geek