System platform: CentOS 6.6 x86_64
Bind version: bind-9.10.2
Preparatory work
Download bind source package, omit ...
Install development Kit, omit ...
Installation:
Decompression bind-9.10.2.tar.gz
#tar XVF BIND-9.10.2.TAR.GZ#CD bind-9.10.2/#./configure-h
#./configure--prefix=/usr/local/bind--mandir=/usr/share/--sysconfdir=/etc/named/--disable-ipv6--disable-chroot --enable-threads #make-j 2 && make install
#ln-S/usr/local/bind/bin/*/usr/bin/#ln-S/usr/local/bind/sbin/*/usr/sbin/
#groupadd-R named#useradd-r-G named-m-s/sbin/nologin Named#mkdir/usr/local/bind/var/run/named#chown named:named/us R/local/bind/var/run/named#ll-d/usr/local/bind/var/run/named/
#[-d/etc/named/] | | Mkdir/etc/named#chown named:named/etc/named#[-d/var/named] | | Mkdir/var/named#chown named:named/var/named
Start configuring the base zone file
#dig -t ns . @61.139.2.69 > /var/named/named.ca#cd /var/named/# vim named.localhost$TTL 1D@ IN SOA @ rname.invalid. ( 0 ; serial 1D ; refresh &Nbsp; 1h ; retry 1W ; expire                  3H) ; minimum NS @ a 127.0.0.1 #vim named.loopback$TTL 1D@ in soa @ rname.invalid. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3h ) ; minimum NS @ a 127.0.0.1 PTR localhost. #chown -r named.named /var/named/*
Named.conf Master Profile
#rndc-confgen -r /dev/uramdom > /etc/named/rndc.conf#cd /etc/named/#touch named.conf#vim rndc.conf Command mode :2,11w >> named.conf#cat named.conf#vim named.confoptions { directory "/var/named"; listen-on port 53 {any; }; allow-query {any; }; recursion yes;}; zone "." IN { type hint; file "named.ca";}; zone "localhost" IN { type master; file "Named.localhost"; allow-update { none; };}; zone "0.0.127.in-addr.arpa" IN { type master; file "Named.loopback"; allow-update { none ; };}; # use with the following in named.conf,adjusting the allow list as needed: key "Rndc-key" { algorithm hmac-md5; secret "8vwpbjej8mochopghan5sq=="; };# controls{ inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "Rndc-key"; }; }; #chown -R named.named /etc/named/*
Run named
# named-u named-g# named-u named# netstat-tunpl# tail/var/log/messages View log status, error # IPTABLES-T Filter-i Input-p UD P--dport 53-j Accept remote computer query under the domain name, to see if the normal query
System service scripts for named
#!/bin/bash# named a network name service.# chkconfig: 345 35 75# description: a name server[ -r /etc/rc.d/init.d/functions ] & & . /etc/rc.d/init.d/functionspidfile=/usr/local/bind/var/run/named/named.pidlockfile=/var/lock/ Subsys/namednamed=namedstart () { [ -x /usr/local/bind/sbin/$named ] | | echo "named: command not found " && 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/bind/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&nBSP;;; Stop) stop ;; Restart) restart ;; Reload) reload ;; Status) status ;; *) echo "Usage:named {start|stop|status|reload|restart}" exit 2;; Esac
REDIRECT Zone type
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/4E/wKiom1VE32Xi9nM1AADLIg-CQQo128.jpg "title=" 1.png " alt= "Wkiom1ve32xi9nm1aadlig-cqqo128.jpg"/>
This type of functionality is if the redirect returns a set IP instead of returning an empty result if the domain name is not queried.
So you can use this feature to do some extra service.
Zone "." in {type redirect; File "Redirect.file";}; $TTL 3600@ in SOA ns. example.net. Mail. Example.net. (0 0 0 0 0) @ in NS NS. example.net*. In A 8.8.8.8
Test
This article is from the "Professor" blog, please be sure to keep this source http://professor.blog.51cto.com/996189/1641331
Bind 9.10 source Installation and new redirect types