Setting up subdomains in DNS

Problem:

You have a webserver (or any server) on your local network, and Freesco is configured to forward port 80 (HTTP) to that server. You also have a domain name (say, www.example.com) that points to your public IP address.

When someone from the outside world punches www.example.com into their browser, your webpage shows up. But if you type www.example.com into your browser on your local network, nothing happens.


Solution:

You need to configure Freesco's DNS server for your domain. The DNS configuration is stored in the file /mnt/router/etc/named.hst. Here's how to update it.


Brief version:

Login as root, edit /mnt/router/etc/named.hst, and add one entry per subdomain in the format:

subdomain<TAB>IN<TAB>A<TAB>IPaddress<TAB>

Copy /mnt/router/etc/named.hst to /etc, restart your nameserver with /mnt/router/rc/rc_named restart and you're on your way. Don't forget to update your reverse DNS files as well (see this article for details).


Longer walkthrough for newbies:

Connect to your Freesco box via telnet (under Windows, just type telnet <your router's ip>) and login as root.

Type:

cd /mnt/router/etc
edit named.hst
Now, you need to enter any subdomains you want to use. For our example, we wanted router.example.com to point to 192.168.0.1, www.example.com to point to 192.168.0.10, and mail.example.com to point to 192.168.0.15, so we entered:

router<TAB>IN<TAB>A<TAB>192.168.0.1<TAB>
www<TAB>IN<TAB>A<TAB>192.168.0.10<TAB>
mail<TAB>IN<TAB>A<TAB>192.168.0.15<TAB>
As you can see, the first part of each line is the subdomain you want to use (eg: using router translates to router.example.com). IN and A have special meaning - don't change or omit them. Last is the IP address of the machine the subdomain corresponds to. Don't forget the final <TAB> at the end of each line.

And note that where we say <TAB>, we mean that you should press the TAB key.

Next, press Alt+X to exit, and when the editor asks you to save, press Y to confirm.

Finally, you should restart your nameserver. Type:

cp /mnt/router/etc/named.hst /etc
/mnt/router/rc/rc_named restart
At this point, your new subdomains should be ready to go! Load up your browser and punch in www.example.com (substitute your domain, of course) and your site should appear.

Note that your default domain (or "primary DNS suffix") on all of the machines on your network should be example.com, as well. On Windows XP, for example, you can change your primary DNS suffix under Start|Control Panel|System|Computer Name|Change|More....

Next, you should probably setup your nameserver for reverse DNS lookups as well - click here to see how.