Since a working DNS is necessarily for most of the Linux stuff I need to setup, I reckon this should be my first blog on Linux. For those following this quickie tutorial, note that DNS setup although straight-forward is still moderately complex. This post is meant as companion text for other more comprehensive DNS tutorial. Also, that while I try to step through all the commands, I won't be able able to display the output of these commands. On some part of this tutorial, you'd have to feel your way through the setup.
That said, let happiness begin!
The Domain Name System (DNS) is way for you to associate cryptic IP address into a more human-friendly domain name. To have a valid and usable Internet DNS, you need to register your domain and host it somewhere. In our case, we'll only setup one that is sufficient for testing other network configuration. For this setup, we'll create exampledns.com domain.
Step 1: Install all the necessary packages.
# yum -y install bind bind-utils bind-chroot
# rpm -q bind bind-utils bind-chroot
Note: The yum utility will automatically resolve and install all the dependency packages (you need Internet connection). Use 'rpm' command to quickly verify if the packages was successfully installed on your system.
Step 2: Make a backup of /etc/named.conf configuration file. Edit /etc/named.conf and add the settings below for exampledns.com domain name.
# cp /etc/named.conf /etc/named.conf-original
# cd /etc/
# vi named.conf
options { listen-on port 53 { 127.0.0.1; 192.168.0.2; }; directory "/var/named"; allow-query { localhost; 192.168.0.0/24; }; allow-transfer { localhost; 192.168.0.0/24; }; recursion yes; }; zone "exampledns.com" IN { type master; file "exampledns.db"; }; zone "0.168.192.IN-ADDR.ARPA." IN { type master; file "exampledns.reverse"; }; |
Step 3: Create the zone file for your exampledns.com domain.
# cd /var/named/chroot/var/named
# vi exampladns.db
$TTL 1D @ IN SOA ns.exampledns.com. root.exampledns.com. ( 001 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum @ IN NS ns.exampledns.com. ns.exampledns.com. IN A 192.168.0.2 exampledns.com. IN A 192.168.0.2 www IN A 192.168.0.2 ftp IN A 192.168.0.2 mail IN A 192.168.0.2 pop IN CNAME mail imap IN CNAME mail |
Note: Carefully take note of the dot or period in ns.exampledns.com. and root.exampledns.com. lines. If it's a fully qualified domain, make sure to put a dot at the end. Or just simply copy and paste the configuration file.
# service named start
Step 6: Create the a reverse DNS.
# cd /var/named/chroot/var/named
# vi exampladns.reverse
$TTL 1H
@ SOA ns.exampledns.com. root..exampledns.com. (
2;
3H;
1H;
1W;
1H; )
NS ns.example.com.
2 PTR exampledns.com.
# service named restart
Note: If everything went well, you should see the following display
Starting named: [ OK ]
If you encounter any problems (ie. syntax errors, etc), the best place to start troubleshooting is the /var/log/messages.
Step 7: Since this is only local domain for testing networking setup, you need to point your resolver back to your local machine. Edit /etc/resolv.conf file and insert the following settings on the first line of the file.
nameserver 192.168.0.2
Step 8: Test your local DNS setup.
$ dig any exampledns.com (testing the information on your exampledns.com domain)
$ dig mx exampledns.com (testing MX record for mail server setup later on)
$ dig -x 192.168.0.2 (test reverse lookup for DNS)
$ ping ftp.exampledns.com (testing domain using ping)
For setting up local DNS for testing, this ought to do it. Also, this Fedora 8 Quickie DNS Setup Tutorial is meant to compliment the more detailed DNS howto found here.
Happy hacking!

1 comment:
Interesting to know.
Post a Comment