I’ve had this annoying problem ever since I set up my own web server at home, and that was about 5 years ago. Though the problem can be quite easily dodged in Windows and even more easily avoided in Linux, it’s been a nail in my eye for half a decade. Today I fixed it once and for all.
The problem is that I can’t use my domain name to access my server from within my LAN. Every time I type blog.fredrikbostrom.net into my browser I only get the login screen of my ADSL router. Not very helpful. So what I’ve had to do is type the local IP address instead of the domain name. This works for ssh and such, but when viewing my website wich contains references to stylesheets and other things using the domain name, it just doesn’t fly.
In Linux this is easily hacked by adding a line to the /etc/hosts file and I suspect that such a solution is possible in Windows as well. However, in my setup at home (Linux on desktop computer, Windows on laptop) this solution is only plausible for the desktop, where I in fact have adopted this method. On my laptop, on the other hand, it’s a different story since I’d have to edit the hosts file every time the computer enters or leaves the building. This is where the nail starts itching in my eye.
Ok, I’ve known the solution for a long time already: Install a DNS server on the server machine and make all my computers use my local server as primary DNS server. I’ve even tried this solution once, installing BIND9 and trying to get it configurated. Yes, trying. BIND is a monster to configurate and quite overkill for a small home network like mine, so I’ve always given up after seeing the 100+ page HOWTO.
So it wasn’t until today when the nail again started twisting around in the never healing wound that I yet again rolled up my sleeves and attacked the problem. After doing some serious Googling I found out about another DNS server called dnsmasq which according to testimonials should be “trivial to configure”, especially for home networks. This sounded good, so after a quick ‘aptitude install dnsmasq’ and some editing of the (long but if you look closer not so complicated) configuration file, I had my brand new DNS server up and running. And it worked, hooray! All requests made to anything ending with fredrikbostrom.net now goes directly to my server without taking a detour to my internet provider’s DNS servers, which caused the before mentioned problem.
So from now on I can write my own testimonial that setting up a simple DNS server for a home network using dnsmasq in fact is trivial (key evidence being that I’m writing this post using my blog’s web interface on my laptop). The only line I changed in the config file was the ‘local=/localnet/’ line to include my own domain name (i.e. ‘local=/localnet/fredrikbostrom.net/’). In other words: ipmasq FTW.