Setting up reverse DNS for your subdomains

Problem:

You've got a domain setup in DNS (using Freesco) to resolve to a machine on your LAN, as explained here. Now, you can visit your website from the local network, but you want to be able to lookup a machine's name based on its IP address.


Solution:

You need to configure Freesco's DNS server for reverse DNS lookups. The DNS configuration is stored in one of three files, depending on your local addressing scheme.

If your LAN uses this block of addressesThen use this configuration file
192.168.*.*/mnt/router/etc/named192.rev
172.16.*/mnt/router/etc/named172.rev
10.*.*.*/mnt/router/etc/named10.rev


Brief version:

Login as root, edit the file named above, and add one entry per subdomain in the format:

y.x<TAB>IN<TAB>PTR<TAB>subdomain.DOMAIN.<TAB>

A couple of notes: y.x refers to the last two octets of your IP address in reverse order (eg: for 192.168.42.76, you'd use 76.42). subdomain is your subdomain, and .DOMAIN. is literal text - don't alter it.

Copy your reverse DNS file to /etc, restart your nameserver with /mnt/router/rc/rc_named restart, and you're done.


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 named192.rev
NOTE: You need to replace named192.rev above with the appropriate filename, as explained in the table at the top of this page.

Now, you need to enter any subdomains that you want to setup. For our example, we wanted 192.168.0.1 to resolve to router.example.com, 192.168.0.10 to resolve to www.example.com, and 192.168.0.15 to resolve to mail.example.com, so we entered:

1.0<TAB>IN<TAB>PTR<TAB>router.DOMAIN.<TAB>
10.0<TAB>IN<TAB>PTR<TAB>www.DOMAIN.<TAB>
15.0<TAB>IN<TAB>PTR<TAB>mail.DOMAIN.<TAB>
This is a bit tricky. The first item on each line is the LAST TWO octets of your IP address, in reverse order (eg: if your address was 192.168.47.92, you'd use 92.47). If you're using 10.x.x.x addresses, it's the last THREE octets in reverse order.

IN and PTR have special meaning - don't change or omit them. Next is the subdomain you want to setup, followed by a period, followed by the word DOMAIN, followed by another period. 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*.rev /etc
/mnt/router/rc/rc_named restart
At this point, you should be able to type nslookup www.example.com on one of your Windows boxes (or host www.example.com under Linux), and it should return the correct IP address for that domain.

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....