Pages

Wednesday, August 22, 2012

simple ipv4 and ipv6 dns server setup in linux (centos)

Here I have explained the steps to setup a simple dns server for some small experiments. My operation system is CentOS. But the configuration files will be same in other operating systems also. I used bind for dns deamon. There are other options too. But bind is popular and fully documented.
  • Install bind (#yum install bind). In some case bind may be already installed by default (in my machine it is already installed).
  • The configuration file, named.conf should be placed in /etc/. If bind-chroot is installed, the configuration file should be placed in /var/named/chroot/etc/.
  • /var/named will be bind's working directory. If bind-chroot is installed /var/named/chroot will be the working directory. (place .db files in corresponding directory)
 /etc/named.conf (/var/named/chroot/etc/named.conf incase bind-chroot)
zone "example.org" {
        type master;
        file "example.org.db";
};
/etc/named/example.org.db (var/named/chroot/example.org.db incase bind-chroot)
 @       IN      SOA     example.org.    hostmaster.example.org. (
                     2008051200      ; serial
                     1d12h                ; refresh
                     15M                   ; update
                     3W12h               ; expiry
                     2h20M   )          ; minimum

  @       IN     NS      ns1.example.org.

  one     IN     A        56.89.90.2
  @       IN     A        89.89.89.89
  six     IN     AAAA     fe80::2
  six     IN     AAAA     3fff::2
  six     IN     AAAA     fec0::15
  • Replace example.org with the name you want to use.
  • In example.org.db file, the line "one IN A 56.89.90.2" matches the name one.example.org with the IPv4 address 56.89.90.2
  • The line "@ IN A 89.89.89.89" matches the name example.org('@' refers current domain) with ipv4 address 89.89.89.89
  • And the last three lines adds three AAAA IPv6 records for the name six.example.org.
Configure dns server ip address to local machine's address. Now restart the named demon (bind dns server demon)
# service named restart
Check the functioning of dns server by issuing nslookup command.

  • Resolve one.example.org
# nslookup one.example.org
Server:         10.5.1.1
Address:        10.5.1.1#53

Name:   one.example.org
Address: 56.89.90.2

  • Resolve example.org
# nslookup example.org
Server:         10.5.1.1
Address:        10.5.1.1#53

Name:   example.org
Address: 89.89.89.89

  • Reslove six.example.org (IPv6)
# nslookup
> set q=AAAA
> six.example.org
six.example.org has AAAA address fec0::15
six.example.org has AAAA address 3fff::2
six.example.org has AAAA address fe80::2
 If you want better understanding please visit http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-bind.html

1 comment:

  1. i want to configure iIPv6 where ipv4 is allready running what are the changes i need to do on os lavel or config lavel

    thanks for help

    ReplyDelete