Using local domain name from within LAN

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.

Share and Enjoy:
  • Reddit
  • StumbleUpon
  • Technorati
  • del.icio.us
  • Digg

3 Responses to “Using local domain name from within LAN”


  1. 1 chuck

    hi Fredrik, i had a lot of problems setting up my space. all the web browser want to run the show. i am still trying to add music to my space. no luck so far all the programs want your life history. are you living in Finland or u.s. your english is good. i will invite you as a friend if it is ok.i invited younger people but they don’t respond. take care chuck

  2. 2 gordon

    Hey, hope this helps or is of interest

    On most routers i have seen you can change the port that the web managment is on. So instead of port 80 (port that webpages are accessed through) you might use 8080, meaning to access your router you would need to specify the port;

    http://192.168.1.1:8080 or http://www.YourDomainName.com:8080

    Note: In some browsers you need to type the http:// part otherwise they dont know to interpret the information from that port as a webpage (IE has this issue i think?) which is a bit odd.

    From there everything works as normal, and it means that your router doesnt get in the way of any http traffic in any direction.

    Thought this might be worth considerign for home users not running DNS

    This is obviously required to have remote managment of your router on at the same time as your website (without multiple IP addresses assigned and/or headache), though i dont recommend leaving it on perminantly as it is a security risk.

  3. 3 Barry Samuels

    Fredrik

    I have just come across this article after doing a search and it seems that dnsmasq is just what I need for my home network.

    Many thanks for taking the trouble to write about it. It has certainly helped me out.

Leave a Reply