Named is not reloading correctly when I add a domain

On some systems, the named boot script provided with the bind rpms don't seem to reliably reload the named program. You can obtain a new named boot script by running the following (RedHat):

cd /etc/init.d
mv named named.backup
wget http://www.directadmin.com/named
chmod 755 named
/sbin/chkconfig named reset

This boot script uses are more direct method of reloading named.

Note, if you're using debian, use:

#!/bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin

# for a chrooted server: "-u bind -t /var/lib/named"
# Don't modify this line, change or create /etc/default/bind9.
OPTIONS=""

PID_FILE=/var/run/bind/run/named.pid

case "$1" in
    start)
	echo -n "Starting domain name service: named"

	modprobe capability >/dev/null 2>&1 || true

	# dirs under /var/run can go away on reboots.
	mkdir -p /var/run/bind/run
	chmod 775 /var/run/bind/run
	chown root:bind /var/run/bind/run >/dev/null 2>&1 || true

	if [ ! -x /usr/sbin/named ]; then
	    echo "named binary missing - not starting"
	    exit 1
	fi
	if start-stop-daemon --start --quiet --exec /usr/sbin/named \
		--pidfile /var/run/bind/run/named.pid -- $OPTIONS; then
	    if [ -x /sbin/resolvconf ] ; then
		echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo
	    fi
	fi
	echo "."	
    ;;

    stop)
	echo -n "Stopping domain name service: named"
	#if [ -x /sbin/resolvconf ]; then
	#    /sbin/resolvconf -d lo
	#fi
	#/usr/sbin/rndc stop
	kill `cat $PID_FILE`
	echo "."	
    ;;

    reload)
	#/usr/sbin/rndc reload
	kill -HUP `cat $PID_FILE`
    ;;

    restart|force-reload)
	$0 stop
	sleep 2
	$0 start
    ;;
    
    *)
	echo "Usage: /etc/init.d/bind {start|stop|reload|restart|force-reload}" >&2
	exit 1
    ;;
esac

exit 0

if you're using FreeBSD, use:

#!/bin/sh

#bootscript for named

# Source function library.
. /usr/local/etc/rc.d/functions

pidfile=/var/run/named.pid
if [ ! -e $pidfile ]; then
	pidfile=/var/run/named/pid
fi


start() {
	echo -n "Starting Named: ";

	COUNT=`ps ax | grep /usr/sbin/named | grep -v grep | grep -c named`

	if [ "$COUNT" -gt 0 ]; then
		echo "named is already running.";
		exit 0;
	fi

        daemon /usr/sbin/named -u bind
        RETVAL=$?
        if [ "$RETVAL" = "0" ] && touch /var/spool/lock/named
	then
		echo -e "\t\t[ OK ]";
	else
		echo -e "\t\t[ FAILED ]";
	fi
}

stop() {
        echo -n "Stopping Named: "
	#killall named 2> /dev/null

	PIDS=`ps ax | grep /usr/sbin/named | grep -v grep | cut -d\  -f1`
	kill -9 $PIDS

        RETVAL=$?
        if [ "$RETVAL" = "0" ] && rm -f /var/spool/lock/named
	then
		echo -e "\t\t[ OK ]";
	else
		echo -e "\t\t[ FAILED ]";
	fi
	sleep 1;
	killall -9 named 2> /dev/null
}

restart() {
	echo -n "Restarting Named: "
	/usr/sbin/ndc restart > /dev/null
	RETVAL=$?
        if [ "$RETVAL" = "0" ];
        then
                echo -e "\t\t[ OK ]";
        else
                echo -e "\t\t[ FAILED ]";
        fi
}

reload() {
	echo -n "Reloading Named: "
	#/usr/sbin/ndc reload
	kill -HUP `cat $pidfile`
	RETVAL=$?
        if [ "$RETVAL" = "0" ];
        then
                echo -e "\t\t[ OK ]";
        else
                echo -e "\t\t[ FAILED ]";
        fi
}



case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        #restart
	stop
	start
        ;;
  reload)
	#reload
	stop
	start
	;;	
  status)
        status named
        ;;
  *)
        echo "Usage: named {start|stop|restart|reload|status}"
        exit 1
esac

exit $RETVAL


 
troubleshooting/named.txt · Last modified: 2010/03/02 05:00 by muscardin
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Please visit Automatic Backlinks to start earning free backlinks Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki Easy, wiched and cheapest term papers in the US