|Date:||16 April 2008|
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 rhodesmill.org or google.com, 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:
local-ttl=1 address=/mail.home/192.168.1.2 address=/gamebox.home/192.168.1.3 address=/printer.home/192.168.1.5
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 192.168.1.3, but it could not answer the reverse question, “What name belongs to the IP address 192.168.1.3?”
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:
192.168.1.2 mail.home 192.168.1.3 gamebox.home 192.168.1.5 printer.home
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.