LAN DNS Resolution with WRT54G DD-WRT’s DNSMasq (Linux and Windows 7)

I have a ton of computers.

I have a quad-core AMD box (running Fedora 11), an AMD Phenom II X4 955 Black Edition box (running Windows 7), a few random head-less desktops, a laptop (F11) and a netbook (F11).

I run a fileserver on one box, I run an X session through ssh on my Windows box to access linux GUI stuff, I frequently transfer files between computers and I wanted to be able to access them by my defined hostname rather than the dynamic IP address my router assigned them (WRT54G running DD-WRT v24 SP1).

Now you may say, “dude, just give them static IP’s and be done with it.”  I considered that, but I would much rather remember “tophat” and “fractal” than and 192.168.12.  Plus I’m a nerd and if there’s a way, I’ll figure it out.

… so I figured it out.

Windows will automatically report the Hostname of the computer (I think Windows calls it the Computer Name), so you won’t have to configure that.  You will however, have to allow your router to cache the hostnames and resolve them to IPs, and you will need to configure Linux to report the hostname when a DHCP lease is acquired.

Configure Router

  1. Login to your router
  2. Click on the “Services” tab
  3. Under DNSMasq enable both options (“Enable DNSMasq” and “Enable Local DNS”)
  4. Click “Apply Settings”

Configure Linux to Report Hostnames

  1. Disclaimer: This is using Fedora 11 – other distros/versions may vary.
  2. You should really pick a unique hostname per interface, so in the case that they’re both connected there isn’t a conflict.
  3. As root, or with appropriate permissions, edit /etc/sysconfig/network-scripts/ifcfg-{interface} (ie /etc/sysconfig/network-scripts/ifcfg-eth0).
  4. Add this line:
  1. Save the file
  2. Restart the network service (sudo service restart network, or use the GUI)
  3. Release your DHCP lease (sudo dhclient -r)
  4. Renew your DHCP lease (sudo dhclient or ifconfig {interface} down; ifconfig {interface} up)

Configure Windows 7 to resolve hostnames (source)

  1. Go into Network Connections (I just typed “Network Connections” om the start icon -> run box)
  2. Right click on your Network Adapter and go into Properties
  3. Select “Internet Protocol Version 4 (TCP/IPv4)”
  4. Under the General Tab click Advanced
  5. Under the DNS Tab select the radio button that says “Append these DNS suffixes (in order)”
  6. Click “Add…”
  7. Enter a single period in the text box and click “Add.”
  8. Click OK in the “Advanced TCP/IP Settings” Dialog
  9. Click OK in the “Local Area Connection Properties” Dialog

And there you go.

Posted Thursday, September 17th, 2009 under linux, networking, tips and tricks, windows.


  1. Thank you – I was looking for it the whole night :) Actually this solution helped me with the problem “No DNS over VPN”. Initially I could address my boxes by hostname while in LAN. But not over VPN. Over VPN only IP addresses worked (no hostnames). When I input a period for DNS suffix on the remote PCs VPN connection properties it started working, i.e. I started adressing boxes on LAN by the hostname over VPN tunnel, not only IP. Thank you!

  2. No problem, happy it helped. Your comment reminded me of one intricacy I later found out but never updated the post with.

    Under the DD-WRT configuration – Services – Services – DHCP Server: if you leave “Used Domain” as WLAN, the DHCP server will report a domain when a DHCP lease is acquired — you can check to see whether your client cached a domain by finding a line beginning with “search” in /etc/resolv.conf.

    If there is no line, no domain was reported during lease acquisition. If there is a line, usually something like ( then –some– utilities will append this to your query.

    If you type “ping clientname” and it fails, but then type “nslookup clientname” and it successfully returns the client’s IP, then you are probably looking at this problem. In short, the ping utility is appending the domain to the clientname and trying to lookup “clientname.domain…”, which fails.

    A quick solution is to just type “ping clientname.” with a trailing period. This will prevent the automatic appending of the domain. This is an annoying solution, though, and the better way is to remove the search line from the resolv.conf.

    There are two ways to do this, one is to simply remove it with a text editor. However as this file is automatically generated upon lease acquisition it will be rewritten next lease.

    The better way is to change the drop down from “WLAN” to “LAN & WLAN” then release your DHCP lease, then renew it. This will prevent the DHCP server from reporting a domain and therefore prevent your client from caching one. You should no longer have the “search…” line in your /etc/resolv.conf file and addressing hosts by their simple hostname without the trailing period will work.


Leave a Reply