by Brandon Rhodes • Home

Name your home machines using Tomato

Date: 16 April 2008
Update (February 2009): thanks to an email I have just received asking how the mechanism described below is better than just assigning host names in Tomato “normally”, I have discovered that this whole post was rather pointless. There is already a way to assign host names in Tomato: click on “Basic” then on “Static DHCP”, and enter your IP addresses and corresponding host names there. I had thought, from its name, that the “Static DHCP” entries were only relevant when machines were booting (when they use DHCP to ask for their host name), but I was wrong: the host names are also returned by the Tomato DNS server for both forward and reverse DNS requests. So while this post is still useful reading if you want to understand better why you might want to use host names for your home machines, the actual mechanism described below is much more trouble than is actually necessary.

I am enjoying my first weeks of using the Tomato Firmware. I purchased a Linksys WRT54GL wireless router because of its admirable support for third-party firmware like Tomato, which replaces the traditional Linksys setup screens with an alterative system with many more configuration options. I can also connect directly to Tomato over SSH and use it as a very small Linux system! This opens endless possibilities for writing fancy firewall rules and running small embedded applications right at the border of my home network.

The Tomato firmware uses a small DNS server named dnsmasq to answer the steady stream of domain name requests from my home computers. It converts domain names that I type, like or, into the low-level IP addresses with which computers identify each other.

But I also like using hostnames for the machines sitting right in my home, even though they do not have “real names” out on the Internet. I recommend placing local hostnames inside of a top-level domain that is local to your own network. Choose a suffix that differs from all of the top-level domains that exist out on the Internet — avoid .com, .net, or .uk, for example, in favor of something like .home or .myhouse instead. How, I wondered, could I add extra host names to dnsmasq?

After my first glance through the dnsmasq documentation, I thought that a series of address options might be the best way to provide my local hosts with names. So I visited its Tomato setup screen, which is under the DHCP / DNS section of the Advanced configuration options, and entered something like this into the “Custom Configuration” file:


The local-ttl option is necessary because the default value, zero, encourages the host(1) command on my Linux machine to issue a warning message for every host I look up.

This setup seemed to work fine, and made it possible to use hostnames like gamebox.home when connecting from one machine to another on my home network. But I noticed delays when creating SSH connections between home machines, as well as errors in my system logs, and, as a result, discovered that this configuration was only working in the forward direction: dnsmasq knew that gamebox.home was a name for the IP address, but it could not answer the reverse question, “What name belongs to the IP address”

I returned to the dnsmasq documentation, read more thoroughly, and learned that it publishes both forward and reverse names for hosts that it finds in the /etc/hosts file. While the Tomato firmware does not seem to support an editable /etc/hosts file whose contents will reappear when the Linksys router reboots, it does provide an auxiliary flash-based filesystem. So I was able to solve my problem in three steps:

With this improvement, both forward and reverse name lookups now work perfectly! To add or remove a host name in the future, I can simply re-edit the file. Though I once dreaded the inflexibility of small embedded appliances, Tomato has finally convinced me to replace the large, noisy Linux box at the edge of my network with something far more tidy and sleek.