Home > DNS and BIND, linux > DNS and BIND – Quick Setup

DNS and BIND – Quick Setup

August 30th, 2011

named.conf
Create /etc/named.conf file specify the directory location of other files used by DNS:

options {
directory "/var/named";
};
zone "."{
type hint;
file "named.ca";
};
zone "darenmatthews.com"{
type master;
file "darenmatthews.named.hosts";
notify no;
};
zone "3.168.192.in-addr.arpa"{
type master;
file "3.168.192.in-addr.arpa";
};
zone "0.0.127.in-addr.arpa"{
type master;
file "named.local";
};

  • options – Specifies the location of the directory where files for the local DNS server are found (/var/named).
  • zone – Specifies each area of responsibility that the DNS server is aware of and the files associated with that area. These files are located in the directory defined by the directory option.

These zone files are defined in this configuration:

  • named.ca is a local cache of the highest-level DNS servers on the Internet – this is the root name servers, or “root hints” file (see later).
    darenmatthews.named.hosts is the master host file for the darenmatthews.com domain. (A name server can handle many domains, by just adding more of this section and changing the domain and the file).

zone "yourotherdomain.com"{
type master;
file "yourotherdomain.named.hosts";
notify no;
};

  • The file 3.168.192.in-addr.arpa allows the server to do a reverse lookup of the domain.
  • The file named.local contains authoritative information for any hosts that you can access through the current host’s loopback network interface. It normally contains just one host entry, localhost

A Sample DNS File:
Sample DNS File for darenmatthews.named.hosts located in /var/named

@ IN SOA www.darenmatthews.com. postmaster.www.darenmatthews.com. (
20120300801 ;Serial
10800 ; Refresh 3 hours
3600 ; Retry 1 hour
604800 ; Expire 1 week
86400 ) ; Minimum 24 hours
;
; (darenmatthews.com) Name and Mailserver Definition
;
IN NS www.youdomain.com.
IN NS auth00.ns.uu.net.
IN MX 10 www.darenmatthews.com.
;
; (darenmatthews.com) Localhost Definition
;
localhost IN A 127.0.0.1
;
; (darenmatthews.com) Hosts Definition
;
darenmatthews.com. IN A 111.111.111.111
www.darenmatthews.com. IN A 111.111.111.111
ftp.darenmatthews.com. IN A 111.111.111.111
mail.darenmatthews.com. IN A 111.111.111.111

The first line is the Start of Authority (SOA) record for the DNS server. It is qualified as being an IN (Internet) record. (www.darenmatthews.com is the name of the name server itself. and postmaster.www.darenmatthews.com is the e-mail address of the person responsible for this domain (you need to replace the first ‘.’ with an ‘@’ sign)).

  • Serial Number: (a good idea is to use the current date with an additional two digits appended to the end of the date – this allows you to change the DNS files more than once per day. (You must change thhe serial with each change or the changes will not be read).
  • Refresh: In seconds, Is how often hosts re-query name server for record information.
  • Retry: (seconds) – The number of seconds a remote host will wait if it is unable to get authoritative information about a host in the domain.
  • Expire: (seconds) – How long a secondary name server will cache information about a host in your domain before asking for updated values.
  • Minimum: (seconds) – The default period of time that answers from this name server are used before new values will be asked for.

The NS record defines the domain’s name server. Its IP address must be present both in this file and in the reverse IP address mapping file.

MX or Mail Exchange is the mail server. You can have a different mail server to handle all the mail. You may also add your ISP’s address to cache mail if yours goes down. They should be setup to do this.

named.local

Now that the DNS file for the domain has been created, it is now necessary to create the named.local in /var/named:

@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.

IN PTR localhost.

Finalising and starting the DNS Server:
Obtain a named.ca file from ftp.rs.internic.net (cd to the “domain” directory and get the named.ca file).

Make named start on boot:

Redhat/CentOS: chkconfig named on
Start manually: /etc/rc.d/init.d/named start
Check process: /etc/rc.d/init.d/named status

Check for errors. (such as forgetting a period).
For more information visit http://www.linuxdoc.org/HOWTO/DNS-HOWTO.html

ROOT HINTS and RESOLV.CONF

ROOT HINTS:
If the DNS server does not know the address of the requested site, then it will forward the request to another DNS server. In order to do so, the DNS server must know of the IP address of another DNS server that it can forward the request to. This is the job of root hints. Root hints provides a list of IP addresses of DNS servers that are considered to be authoritative at the root level of the DNS hierarchy(also known as root name server).

The root hints file is really nothing more than just a text file that pairs root DNS servers with their IP addresses.

Microsoft:

Windows Server 2003 DNS servers: The root hints are stored in a file named cache.dns that is located in the \Windows\System32\Dns folder.

Linux:
The file named /var/named/root.hints is named in this. /var/named/root.hints should contain this:

;
; There might be opening comments here if you already have this file.
; If not don't worry.
;
; About any leading spaces in front of the lines here: remove them!
; Lines should start in a ;, . or character, not blanks.
;
. 6D IN NS A.ROOT-SERVERS.NET.
. 6D IN NS B.ROOT-SERVERS.NET.
. 6D IN NS C.ROOT-SERVERS.NET.
. 6D IN NS D.ROOT-SERVERS.NET.
. 6D IN NS E.ROOT-SERVERS.NET.
. 6D IN NS F.ROOT-SERVERS.NET.
. 6D IN NS G.ROOT-SERVERS.NET.
. 6D IN NS H.ROOT-SERVERS.NET.
. 6D IN NS I.ROOT-SERVERS.NET.
. 6D IN NS J.ROOT-SERVERS.NET.
. 6D IN NS K.ROOT-SERVERS.NET.
. 6D IN NS L.ROOT-SERVERS.NET.
. 6D IN NS M.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 6D IN A 198.41.0.4
B.ROOT-SERVERS.NET. 6D IN A 128.9.0.107
C.ROOT-SERVERS.NET. 6D IN A 192.33.4.12
D.ROOT-SERVERS.NET. 6D IN A 128.8.10.90
E.ROOT-SERVERS.NET. 6D IN A 192.203.230.10
F.ROOT-SERVERS.NET. 6D IN A 192.5.5.241
G.ROOT-SERVERS.NET. 6D IN A 192.112.36.4
H.ROOT-SERVERS.NET. 6D IN A 128.63.2.53
I.ROOT-SERVERS.NET. 6D IN A 192.36.148.17
J.ROOT-SERVERS.NET. 6D IN A 198.41.0.10
K.ROOT-SERVERS.NET. 6D IN A 193.0.14.129
L.ROOT-SERVERS.NET. 6D IN A 198.32.64.12
M.ROOT-SERVERS.NET. 6D IN A 202.12.27.33

The file describes the root name servers in the world. The servers change over time and must be maintained now and then.

RESOLV.CONF
Local name resolution is done via /etc/hosts file. If you have small network, use /etc/hosts file. DNS (domain name service is accountable for associating domain names with ip address, for example domain yahoo.com is easy to remember than IP address 202.66.66.12) provides better name resolution.

To configure Linux as a DNS client you need to edit or modify /etc/resolv.conf file. This file defines which name servers to use. You want to setup Linux to browse net or run network services like www or smtp; then you need to point to correct ISP DNS servers:

/etc/resolv.conf file
The resolv.conf file typically contains the IP addresses of nameservers (DNS name resolvers) that attempt to translate names into addresses for any node available on the network.

Steps to configure Linux as DNS client, first login as a root:

Step 1: Open /etc/resolv.conf file:

# vi /etc/resolv.conf

Step 2: Add your ISP nameserver as follows:

search isp.com
nameserver 202.54.1.110
nameserver 202.54.1.112
nameserver 202.54.1.115

Note: only a maximum of three nameserver may be used/defined at a time.

Step 3: Test using nslookup or dig:

$ dig www.darenmatthews.com
$ nslookup www.darenmatthews.com

Categories: DNS and BIND, linux Tags:
Comments are closed.