DNS BIND 운영 관리 스크립트

1966 단어 dns
bind 관리를 편리하게 하기 위해 셸 스크립트를 작성하여bind의 start,stop,restart,status 작업을 실현하고 스크립트를/etc/rc.로 복사할 수 있습니다d/init.d/, 서비스 시작을 추가하고bind 서비스를 켜기 시작으로 설정합니다.
스크립트 bind:
#!/bin/bash
# bind  , /etc/rc.d/init.d/, service 
# chkconfig: 345 35 75

# 
BIND_USER=slim
#chroot path
CHROOT_PATH=/home/slim/chroot
#bind install apth
BIND_PATH=/home/slim/bind

if [ `id -u` -ne 0 ]; then
        echo "ERROR:For bind to port 53,must run as root."
        exit 1
fi
case "$1" in
start)
if [ -x $BIND_PATH/sbin/named ];then
        $BIND_PATH/sbin/named -u $BIND_USER -t $CHROOT_PATH -c /etc/named.conf && echo "BIND Server is started."
fi
;;
stop)
        kill `cat $CHROOT_PATH/var/run/named.pid ` && echo "BIND Server is stopped."
;;
restart)
        echo "Restart BIND server."
        $0 stop
        sleep 3
        $0 start
;;
reload)
        $BIND_PATH/sbin/rndc -c $CHROOT_PATH/etc/rndc.conf reload
;;
status)
        $BIND_PATH/sbin/rndc -c $CHROOT_PATH/etc/rndc.conf status
;;
*)
        echo "Usage:$0 start | stop | restart |reload |status"
        exit 1
;;
esac
exit 0
실행 권한 추가:
chmod +x bind
스크립트 bind를 cp bind/etc/rc.로 복사d/init.d/에서 서비스 관리 사용:
service bind start|stop|restart|reload|status
전원 켜기 부팅 추가:
#cd/etc/init.d/
# chkconfig --add bind/* chkconfig 관리에 bind 추가
# chkconfig bind on/* 서비스 활성화
# chkconfig -- list bind/* bind 표시
chkconfig 매개 변수:
#chkconfig -h
chkconfig version 1.3.49.3 - Copyright (C) 1997-2000 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.

usage:   chkconfig [--list] [--type <type>] [name]
         chkconfig --add <name>
         chkconfig --del <name>
         chkconfig --override <name>
         chkconfig [--level <levels>] [--type <type>] <name> <on|off|reset|resetpriorities>

좋은 웹페이지 즐겨찾기