Setting up a DNS Server on Red Hat Enterprise Linux 5.5

Time Required: 20 minutes

Class Materials:

  • Red Hat Enterprise Linux 5.5 64-bit install media

The following steps show how to install your own DNS server into Red Hat Enterprise Linux 5.5

These steps were developed as part of my ten part blog series on installing your own Oracle 11gR2 RAC cluster on VMWare Workstation 8.

I am re-blogging this as a separate post for the sake of clarity to those not interested in the RAC components.

First, locate and mount your RHEL 5.5 install media.

[root@orpheus Server]# cd "/media/RHEL_5.5 x86_64 DVD/Server"
[root@orpheus Server]# pwd
 /media/RHEL_5.5 x86_64 DVD/Server

 
Next load the RPM to support the DNS service:

[root@orpheus Server]# rpm -ivh bind-9.3.6-4.P1.el5_4.2.x86_64.rpm
warning: bind-9.3.6-4.P1.el5_4.2.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:bind                   ########################################### [100%]

 
Now we will need to create or edit four files to start our DNS server:

  • /etc/named.conf
  • /var/named/[domain].zone
  • /etc/resolv.conf
  • /etc/sysconfig/network-scripts/ifcfg-eth0

The /etc/named.conf file is the main configuration file for the named service. This is what provides our DNS resolution.

[root@orpheus Server]# cat /etc/named.conf

options {
        directory "/var/named";
        dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        forwarders { 192.168.1.1; };
};
include "/etc/rndc.key";

zone "hadesnet" IN {
type master;
file "hadesnet.zone";
allow-update { none; };
};

 

In the above example I have created my domain name as hadesnet. Your example will need to reflect what domain name you have or wish to use.

I am also forwarding names I cannot resolve to address 192.168.1.1 which is the DNS server on most home networks. If yours differs then you will need to change this if you wish to be able to talk to the outside internet.

Note that since I am hard-coding this address, if my network settings change as I travel, or I log into a VPN, then my ability to talk to the outside internet from inside my VM will fail.

The /etc/named.conf file references another file called hadesnet.zone. This is where I am going to define IP addresses for my hadesnet domain.

The hadesnet.zone file should be located in /var/named and should look as follows:

[root@orpheus Server]# cat /var/named/hadesnet.zone
$TTL  86400
@ IN SOA      hadesnet. hadesnet.(
42          ; serial (d. adams)
3H          ; refresh
15M         ; retry
1W          ; expiry
1D )        ; minimum

hadesnet.                     IN NS   10.10.1.20
localhost                     IN A    127.0.0.1
orpheus.hadesnet.             IN A    10.10.1.10
eurydice.hadesnet.            IN A    10.10.1.20

 
In the above example we have defined the IP addresses for my machines Orpheus and Eurydice.

Now we need to add our new DNS server to the list of DNS servers on our Linux machines. We do this by adding entries to the /etc/resolv.conf file on all machines that will use the DNS service.

In the following example, I am going to use Orpheus as my DNS server.

[root@orpheus ~]# cat /etc/resolv.conf

nameserver 10.10.1.10     # orpheus DNS server
nameserver 192.168.1.1    # Primary DNS in the domain
search hadesnet # Local Domain

 
Now we have to make an adjustment to our ethernet adapter settings. If not, the /etc/resolv.conf file will get overwritten every 900 seconds by the dhclient-script script

The over write is caused by the DHCP process being refreshed. We can disable this by making modifications to the ethernet adapter configuration files.

We need to navigate to the /etc/sysconfig/network-scripts directory

[root@orpheus ~]# cd /etc/sysconfig/network-scripts

 
Here we will find files named ifcfg-ethn. There is one file for each NIC card.

Edit each file in turn and set PEERDNS=no. If the PEERDNS directive does not exist in the file add it.

My ifcfg-eth0 file looks like this:

[root@orpheus ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:0c:29:4a:b5:db
NETMASK=255.255.255.0
IPADDR=10.10.1.10
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=no

 
Check your resolv.conf file again to make sure the dhclient-script hasn’t overwritten it while you were disabling PEERDNS.

Now we can start our DNS service:

[root@orpheus Server]# service named start
Starting named: [  OK  ]

 
And we will set the service to start on reboot:

[root@orpheus Server]# chkconfig named on

 
Now test the DNS service by looking up an address:

[root@orpheus Server]# nslookup eurydice
Server:         10.10.1.10
Address:        10.10.1.10#53

Name:   eurydice.hadesnet
Address: 10.10.1.20

 
And also test looking up an address we know our DNS service does not serve:

[root@orpheus Server]# nslookup bbc.co.uk
Server:         10.10.1.10
Address:        10.10.1.10#53

Non-authoritative answer:
Name:   bbc.co.uk
Address: 212.58.241.131

 

Advertisements

5 thoughts on “Setting up a DNS Server on Red Hat Enterprise Linux 5.5

  1. Hi Gruff, Morning

    I’ve had a problem in my configuration with my development DNS, because I’m trying build or configure, but the message is clear below.

    Can you help me about this error.

    I use VMWare Workstartion 9 in Windows 8 RHEL 6.5

    Thanks a Lot

    Fernando
    Sao Paulo, Brazil

    [root@eurydice etc]# service named start
    Starting named:
    Error in named configuration:
    localdomain.zone:12: NS record ‘10.10.1.20’ appears to be an address
    zone localdomain/IN: NS ‘10.10.1.20.localdomain’ has no address records (A or AAAA)
    zone localdomain/IN: not loaded due to errors.
    _default/localdomain/IN: bad zone

  2. Dear Gruff, Afternoon

    What’s my problem in my configuration.. Cant you clear my mind..I’m unseen any error in my configuration because I follow your instructions in you Blogger..

    Regards

    Fernando

    Starting named:
    Error in named configuration:
    localdomain.zone:12: NS record ‘10.10.1.20’ appears to be an address
    zone localdomain/IN: NS ‘10.10.1.20.localdomain’ has no address records (A or AAAA)
    zone localdomain/IN: not loaded due to errors.
    _default/localdomain/IN: bad zone

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s