Bind Configuration
Bind Configuration
on setting up secure DNS server using Bind. I have used one them time after time called:
Linux Howto: Chroot Bind How To. One of the things I do not like about it is that I had to read
over things which I really do not need to know or already know. So I have put together this
quick wow To based on this great how to. Setting up secure DNS server using bind is not very
complicated.
Let us dive into this. First we create user and set up directory structure.
vi /etc/sysconfig/syslog
edit the line which starts with SYSLOGD_OPTIONS and edit it to look like:
SYSLOGD_OPTIONS=”-m 0 -a /chroot/named/dev/log”
Let us restart syslog to use new settings and let us secure the physical files on the server.
/etc/rc.d/init.d/syslog stop
/etc/rc.d/init.d/syslog start
chown root /chroot
chmod 700 /chroot
chown named:named /chroot/named
chmod 700 /chroot/named
cd /chroot/named
chattr +i etc/localtime var
Let us clean up previous bind install since most linux installations have named (bind) pre-
installed.
rpm -qa |grep bind
rpm -e --nodeps <copy-paste-all-the-packages-separated-by-space>
Let us get the source files for bind and install it. At time of writing, bind 9.4.1 is the latest.
wget http://ftp.isc.org/isc/bind9/9.4.1/bind-9.4.1.tar.gz
tar zxpfv bind-*.gz
cd bind*
./configure
make && make install
#!/bin/sh
#
# named This shell script takes care of starting and stopping
# named (BIND DNS server).
#
# chkconfig: 345 55 45
# description: named (BIND) is a Domain Name Server (DNS) \
# that is used to resolve host names to IP addresses.
# probe: true
#
# Source function library.
. /etc/rc.d/init.d/functions
#
# Source networking configuration.
. /etc/sysconfig/network
#
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
#
[ -f /usr/local/sbin/named ] || exit 0
[ -f /chroot/named/etc/named.conf ] || exit 0
#
# See how we were called.
case "$1" in
start)
# Start daemons.
echo -n "Starting named: "
daemon /usr/local/sbin/named -u named -t /chroot/named -c /etc/named.conf
echo
touch /var/lock/subsys/named
;;
stop)
# Stop daemons.
echo -n "Shutting down named: "
kill `pidof named`
echo
rm -f /var/lock/subsys/named
;;
status)
status named
exit $?
;;
restart)
$0 stop
$0 start
exit $?
;;
reload)
/usr/local/sbin/rndc reload
exit $?
;;
probe)
# named knows how to reload intelligently; we don't want linuxconf
# to offer to restart every time
/usr/local/sbin/rndc reload >/dev/null 2>&1 || echo start
exit 0
;;
#
*)
echo "Usage: named {start|stop|status|restart|reload}"
exit 1
esac
#
exit 0
This should get you started. Now just create appropriate zone files and you are good to go.
————————————-
DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but
not least.. I am not responsible for any damage caused by this posting. Use at your own risk.
Comments (13)
1. George
It seems that I can not add /chroot/named/etc/named.conf due to permission restrictions. I am still
looking for help. Any ideas?
2. Bill Holt
I also, can not add /chroot/named/etc/named.conf due to permission restrictions. I am looking for help.
Any ideas?
3. CrazyToon
4. George
5. CrazyToon
If you would like to make it more secure then you should. I have a lot of clients who prefer to not have +i
set up on etc.
6. francisco
Hey! can you help? I have followed your guide but still one minor problem: error: named dead but subsys
locked
it wont start.
7. Peter
I have the same error. “named dead but subsys locked” when executing “./named status” and the
application will not start. Did you find a solution to this issue?
8. Bill Hudson
Can your above instructions regarding Bind work without chroot? Also, do you have any info on setting up
zone files? Thanks for putting the above info together, it’s appreciated.
Bill
9. maz
Hi, this link is very good, i have the same bind9.3.6 on centos 5.4, i am getting this kind of messages in
the server
Sep 19 18:49:07 centos1 named[23130]: client xxx.xxx.xxx.xxx#60923: update ‘backup.com/IN’ denied
Sep 19 18:49:07 centos1 named[23130]: client 9x.xxx.xx.xxx#55432: update ‘bacups.com./IN’ denied
Sep 19 18:51:17 centos1 named[23130]: network unreachable resolving ‘ns1.inmel.r
u/AAAA/IN’: 2001:xxx:1xx:0x:xxx:xxx:xx2:17#53
BR,
MAZ
10. david
ok this didnt work for me? give me auth errors on just about everything when I try to start named
and key errors but the ke is in the rndc.conf
///////////////////////////////////////////////////////////////
messages:Feb 10 19:01:17 server1 rsyslogd: Warning: backward compatibility layer added to following
directive to rsyslog.conf: addunixlistensocket /chroot/named/dev/log
messages:Feb 10 19:01:24 server1 kernel: warning: `named’ uses 32-bit capabilities (legacy support in
use)
messages:Feb 10 19:01:24 server1 named[4379]: starting BIND 9.7.2-P3 -u named -t /chroot/named
-c /etc/named.conf
messages:Feb 10 19:01:24 server1 named[4379]: built with ‘–without-openssl’
messages:Feb 10 19:01:24 server1 named[4379]: using up to 4096 sockets
messages:Feb 10 19:01:24 server1 named[4379]: loading configuration from ‘/etc/named.conf’
messages:Feb 10 19:01:24 server1 named[4379]: /etc/named.conf:15: unknown key ‘rndc-key’
messages:Feb 10 19:01:24 server1 named[4379]: loading configuration: failure
messages:Feb 10 19:01:24 server1 named[4379]: exiting (due to fatal error)
messages:Feb 10 19:03:26 server1 named[5442]: starting BIND 9.7.2-P3 -u named -t /chroot/named
-c /etc/named.conf
messages:Feb 10 19:03:26 server1 named[5442]: built with ‘–without-openssl’
messages:Feb 10 19:03:26 server1 named[5442]: using up to 4096 sockets
messages:Feb 10 19:03:26 server1 named[5442]: loading configuration from ‘/etc/named.conf’
messages:Feb 10 19:03:26 server1 named[5442]: /etc/named.conf:15: unknown key ‘rndc-key’
messages:Feb 10 19:03:26 server1 named[5442]: loading configuration: failure
messages:Feb 10 19:03:26 server1 named[5442]: exiting (due to fatal error)
messages:Feb 10 19:10:30 server1 named[5918]: starting BIND 9.7.2-P3 -u named -t /chroot/named
-c /etc/named.conf
messages:Feb 10 19:10:30 server1 named[5918]: built with ‘–without-openssl’
messages:Feb 10 19:10:30 server1 named[5918]: using up to 4096 sockets
messages:Feb 10 19:10:30 server1 named[5918]: loading configuration from ‘/etc/named.conf’
messages:Feb 10 19:10:30 server1 named[5918]: /etc/named.conf:15: unknown key ‘rndc-key’
messages:Feb 10 19:10:30 server1 named[5918]: loading configuration: failure
messages:Feb 10 19:10:30 server1 named[5918]: exiting (due to fatal error)
messages:Feb 10 19:32:50 server1 named[7405]: starting BIND 9.7.2-P3 -u named -t /chroot/named
-c /etc/named.conf
messages:Feb 10 19:32:50 server1 named[7405]: built with ‘–without-openssl’
messages:Feb 10 19:32:50 server1 named[7405]: using up to 4096 sockets
messages:Feb 10 19:32:50 server1 named[7405]: loading configuration from ‘/etc/named.conf’
messages:Feb 10 19:32:50 server1 named[7405]: /etc/named.conf:22: unknown key ‘rndc-key’
messages:Feb 10 19:32:50 server1 named[7405]: loading configuration: failure
messages:Feb 10 19:32:50 server1 named[7405]: exiting (due to fatal error)
//////////////////////////////////////////////////////////////////
Love BSD Not so shure about this expensive RHEL with sad excuse for support….
Thanks for any help in advance!
~D
11. islamay
12. Cage
CrazyToon,
I hope you are still around and get this.
I just wanted to say thank you!
After digging and researching for over 60 hrs on multiple setups to rebuild every aspect of a server for the
first time alone, DNS being my most challenging daemon…
You Rock!
You wright the best clear cut clean directions without all the extra stuff we don’t need when pressed.
I hope you do more in the future. I just take my hat off to ya. You should put a book out, heck, I would
help!
Latter
George L.
Minnesota, USA
Thanks for the kind words George. Glad i could help you out.