1. Parsing packages
# wget http://ftp.isc.org/isc/bind9/9.7.3/bind-9.7.3.tar.gz # tar xvf bind-9.7.3.tar.gz # cd bind-9.7.3.tar.gz# ./configure --prefix=/usr /local/bind9 --sysconfdir=/etc/named/ --disable-ipv6 --enable-threads --enable-epoll --disable-chroot# make# make install #但是安装完成之后什么都没有, you can take a look at # ls /etc/namedbind.keys #就只有一个文件 # ls /var/named ... no such file or directory #连目录都没有 # ls doc #看看有没有什么模板arm doxygen Makefile makefile.in misc xsl #没有模板 # cd /usr/local/bind9 #到安装目录看看 # lsbin include lib sbin share var #没有模板 # cd bin/# lsdig host isc-config.sh nslookup nsupdate #这些命令都有 # cd  ... /sbin/# lsarpaname dnssec-keygen dnssec-verify named named-journalprint ddns-confgen dnssec-revoke genrandom named-checkconf nsec3hash dnssec-dsfromkey dnssec-settime Isc-hmac-fixup named-checkzone rndcdnssec-keyfromlabel dnssec-signzone lwresd named-compilezone rndc-confgen# rndc-bash: rndc: command not found #命令也不能用 # vim /etc/profile.d/bind9.conf.shexport path=/usr/ Local/bind9/bin:/usr/loacl/bind9/sbin: $PATH # . /etc/profile.d/bind9.sh# rndc #现在才能使用, but the main profile is not, RNDC key is not, all of them to write manually
2, master configuration file/etc/named/named.conf sample
# mkdir/var/named# cd/etc/named/# vim named.confoptions {directory "/var/named"; Pid-file "/var/run/named.pid";}; Zone "." in {type hint; File "named.ca";}; Zone "localhost" in {type Master; File "Localhost.zone"; allow-update {none;};}; Zone "0.0.127.in-addr.arpa" in {type Master; File "Named.local"; allow-update {none;};};
3. Generate rndc.conf
# rndc-confgen > /etc/named/rndc.conf# cat rndc.conf...# use with the following in named.conf, adjusting the allow list as needed:# key "Rndc-key" {# algorithm hmac-md5;# secret "xqwtfcruet4n8zcyjbnn1w==";# };## controls {# inet 127.0.0.1 port 953# allow { 127.0.0.1; } keys { "Rndc-key"; };# };# end of named.conf #将上面要加入的内容加到named later # vim named.conf in the. conf file #把配置文件后N行复制到named. conf, and remove the comment key "Rndc-key" { algorithm hmac-md5; secret "xqwtfcruet4n8zcyjbnn1w==";}; Controls { inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "Rndc-key"; };};
4. Create a Zone resolution library in/var/named
# cd /var/named# dig -t ns . @172.19.0.6 > /var/named/named.ca # vim localhost.zone$ttl 1d@ in soa localhost. admin.localhost. ( 0 2H 1h 1W 3H ) @ in ns Localhost.localhost. IN A 127.0.0.1# cp localhost.zone named.local# vim named.local$ttl 1d@ in SOA localhost. admin.localhost. ( 0 2H 1H 1W 3H ) @ in ns locAlhost.1 in ptr localhost.# useradd -r named# man -m /usr/local/bind9/share/man/ named# chown root:named ./*# chmod 640 ./*# ll# chown root:named /etc/named/*# chmod 640 /etc/named/*# named -u named -f -g -4
Open a terminal to see if the native address starts listening
# ss-tunl# RNDC Status #现在named已经开始工作了
5. Create a service script
# vim /etc/rc.d/init.d/named #每次启动都要指定, it's too much trouble, write a script #! /bin/bash# chkconfig: 2345 70 50# description: named[ -r /etc/rc.d/ init.d/functions ] && . /etc/rc.d/init.d/functionspidfile=/var/run/ Named.pidlockfile=/var/lock/subsys/namednamed=namedstart () { [ -x /usr/ local/bind9/sbin/$named ] | | exit 4 if [ -f $LockFile ]; then echo -n "$named is already running ..." failure echo exit 5 fi echo -n "starting $named: " daemon --pidfile "$PidFile" /usr/local/bind9/sbin/$named -u named -4 RETVAL=$? echo if [ $RETVAL -eq 0 ]; then touch $LockFile return 0 else rm -f $LockFile $PidFile return 1 fi}stop () { if [ ! -f $LockFile ];then echo "$named is not started." failure fi echo -n "stopping $named: " killproc $named RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f $LockFile return 0} Restart () { stop sleep 1 start} Reload () { echo -n "reloading $named: " killproc $named -HUP RETVAL=$? echo return $RETVAL}status () { if pidof $named > /dev/null && [ -f $PidFile ]; then echo "$named is running ..." else echo "$named is stopped ..." fi}case $ 1 instart) start ;; Stop) stop ;; Restart) restart ;; Reload) reload ;; Status) status ;; *) echo "Usage:" exit 2;; Esac
# bash -n /etc/rc.d/init.d/named# chmod +x /etc/rc.d/init.d/named# chkconfig --add named# service named startstarting named: [ OK ]# service named startStarting named: [FAILED]# service named stopStopping named: &nbsP; [ ok ]# service named restartStarting named: [ ok ]stopping named: [ ok ]# service named reloadreloading named: [ ok ] # service named statusnamed is stopped... #出错了这里应该是named is running# chown -r named:named / usr/local/bind9/var/run/ #改下权限 # vim /etc/named/ named.confpid-file "/usr/local/bind9/var/run/named.pid"; # This place changes # vim /etc/rc.d/init.d/namedpidfile=/usr/local/bind9/var/run/named.pid . #这也改 # service named stop stopping named: [ OK ]# service named stop Stopping named: [FAILED]# service named startstarting named: [ OK ]# Service named statusnamed is running...# service named stop stopping named: [ ok ]# service named statusnamed is stopped ...
This article is from the "three elder brother" blog, please be sure to keep this source http://523958392.blog.51cto.com/9871195/1625849
Compile and install bind and SYSV service scripting