DNS howto's for RHEL5

Share your expert knowledge and show off your skills.
Posts: 8
Joined: Wed Mar 12, 2008 11:44 am
Location: End of Road. . . .

DNS howto's for RHEL5

Postby CyberBob » Tue Mar 03, 2009 2:51 pm

Some people think that configuring dns in rhel5 is a little bit tricky. I have included a howto on configuring dns in rhel5. please help me with your feed back to improve this document. please contact me cyberbob.thedarklord@gmail.com
you can also reach me at irc, i m available on freenode as


How to configure DNS on RHEL5.

Before configuring any server check your hostname it should be FQDN(Fully Qualified Domain Name)
by command

changing hostname in run level 3 may be in run level 5 machine will hange***

#init 3

#hostname pc1.cyberdyne.net


#vi /etc/sysconfig/network
and edit this line to


save and exit the file.
# reboot or change run level
# init 5

RedHat starting from version RHEL4 has included extras layer of security with the name of SELINUX.
Configure selinux properly for specific services like bind,apache,squid,dhcp,ftp etc otherwise disable it completely.
(Dont keep it just enable without proper configuration).

To check the status of selinux
SELinux status: disabled

If it is enable on you system then open the file
# vi /etc/sysconfig/selinux
and the change the following line to


and save the file.

(When ever you change the status of selinux you have to reboot the machine)

-check the bind package

----------------------------BIND configration--------------------------------------

#rpm -qa |grep ^bind

# rpm -q caching-nameserver

go the direcoty
# cd /var/named/chroot/etc

In this file will be with the name of named.caching-nameserver.conf
copy this file in the same directory with the name of named.conf

# cp named.caching-nameserver.conf named.conf

Change the group of named.conf file

# chown root.named named.conf
make the symbolic link of named.conf in the /etc dir

# ln -s /var/named/chroot/etc/named.conf /etc/named.conf

# Now open named.conf file and change the followings lines.

Add ip address of server in bracket.
# vi named.conf

listen-on port 53 {;; };

// I am using here simple approach of single view.For more advance configuration
// named.conf required multiple views which will be discussed Inshalla later on.

Add any in allow-query
allow-query { localhost; any; };

Add any in localhost_resolver

view localhost_resolver {
match-clients { localhost; any; };

save and exit the file.

Now check the systax error of this file by this command

Now open another file in the same directory
# vi named.rfc1912.zones
and change the localdomain to your domain name

zone "cyberdyne" IN {
type master;
file "cyberdyne.forzone";

and save the file
#now to the the directory
# cd /var/named/chroot/var/named/

In this directory you will see a file named.local copy this file with the same names as you have
mettioned in named.rfc1912.zones in zone information of your domain (in tab of file"cyberdyne.forzone")

# cp named.local cyberdyne.forzone

Change the group of this file.
#chown root.named cyberdyne.forzone

Now open this file

#vi cyberdyne.forzone

and change the localhost with your fully Qualified Domain name like

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

pc1.cyberdyne.net. IN A
ali.com. IN A

Delete the PTR line from this file.
And record the record in this file ans mention above.
Pay special attention to DOT in this file.
There should alwayes be DOT at the end of record named as
pc1.cyberdyne.net. IN A
There must not be DOT at end of ip address

Then save and exit this file.

Now start/restart the named servics.
# service named restart

And check the log file /var/log/messages carefully for any error message

#Now open the file /etc/resolv.conf to the the cleint about its DNS server
# vi /etc/resolv.conf
and add this line


save and exit the file.

#Then check DNS from you cleint machine by commands, host,nslookup ,dig


#dig pc1.cyberdyne.net

There should a Answer section in your output which will show the desired query answer.

pc1.cyberdyne.net. 86400 IN A

Return to “Howto's & Tip n' Tricks”

Who is online

Users browsing this forum: No registered users and 1 guest