As previously mentioned, I recently got a Dreamplug which I am using as a media server. Hopefully.
One of my requirements for something as general purpose as a media server is that I be able to tell people “feel free to play some of my music, just go to carsonella.home and look around.” (My smallest computer is called carsonella, get it?) I specifically don’t want to have to tell people “Go to… oh wait let me check what IP carsonella is on… [3 minutes later] 192.168.0.108. No, that’s a web address, just put it in your browser. Yeah, Firefox is actually a web browser.” And etc.
So: I want names. Mapped to IPs. I’m used to doing this for my (linux) computer with /etc/hosts, so I thought I would be able to do this for my local network via some magic setting in my router, but it turns out I just want my own DNS server. Also I’m not an IT professional, who knew?
I’ve got a D-Link DIR-655 (HW version B1, firmware 2.00NA) router and a Dreamplug Running Debian Squeeze. And no JTAG adapter, so I really don’t want to mess anything up.
This should work for any Debian/D-Link setup, but caveat emptor.
It turns out that there are only a couple of things that need to happen to make this work, but they’re independent of each other so I couldn’t find any tutorials that collect it all in one place. Basically:
- install dnsmasq on the plug
- configure dnsmasq on the same
- configure my D-Link to use the plug as the DNS server
- and, separately, tell it not to use the ISP’s DNS settings.
That last point really bit me.
1) Installing dnsmasq is as easy as install anything on debian:
apt-get install dnsmasq
2) Configuring it involves editing a couple of files: I set my
/etc/resolve.conf to look like:
I think that the first two lines tell this computer that it’s responsible for handling everything that ends with a
.home pseudo-TLD. Honestly this is just cargo-cult server setup and I would appreciate any comments or corrections, and don’t take my word for this.
I know it’s appealing to make computers on your network have no dots in them, but all kinds of services (e.g. Firefox, and apparently most of Windows) will assume that you messed up your url if you didn’t put in at least one dot and will try to “fix” it for you.
The third line is essential: it tells the plug that it is its own nameserver, and to check itself before it checks anything else for a real name. It also, apparently, sets up local caching– hopefully this will improve DNS lookup times for common sites by a few ms. (I’ve noticed mine go from 18-20ms down to 2, when I’m plugged into my ethernet.)
The last two lines configure it to use opendns, a great (better than your ISP’s) DNS service. A problem with it, though, is that by default if you try to visit a nonexistent domain it will show you an OpenDNS “search” page filled with ads. You can follow these instructions to get proper 404 behavior. If that’s too much work you can use Google’s public DNS, which does the right thing by default, but then Google will know Even More about you.
I then modified /etc/hosts to look like:
I am reasonably certain that the
.home part of
carsonella.home there must match what is set as the domain in resolv.conf
3) Configuring the D-Link to use the plug as the DNS server isn’t terrible, if you know where to look.
The first thing that I needed to do was to get my dreamplug to have a static IP. Since I didn’t want to mess with network settings on the plug (no JTAG means no debugging if things go to hell) I just used the D-Link’s “reserve IP” functionality.
You find the reserve IP settings at the bottom of the “Setup ? Network Settings” page in the D-Link admin. One bug there was that I needed to click “Save Settings” at the top for the settings to take effect, even though they looked saved and the DIR-655 told me that there was “nothing new to save.”
Choose some IP to reserve for the dreamplug, for example 192.168.0.128.
To tell the D-Link that it needs to use your plug for DNS you need to go to “Setup ? Internet” and click on the “Manual Internet Connection Setup” button.
Here you need to fill in the IP you chose for your plug as the Primary DNS Address. I also recommend putting in one of the IPs you used as a nameserver as the secondary DNS addres in case your computer goes down.
Save these settings.
4) Go back to “Setup ? Network Settings” and make sure
Enable DNS Relay is unchecked. Without this your router will ignore all of your settings and just assign your local computers DNS settings as provided by your ISP.
Save these settings. (I’m pretty sure you don’t want to do this before you’ve configured a new nameserver, because changing settings on the D-Link has some random chance of renewing your DHCP lease, and if you do that without a DNS server you won’t be able to find any damned thing.)
Or at least I am, this was supposed to be a quick reminder in case I ever needed to do this again.