The compilation and installation of DNS source code,
Official bind:www.isc.org
Here we are compiling the bind-9.9.5.tar.gz version
1. Compiling environment
Desktop Platform Development
Development tools
Server Platform Development
2. Expand the installation package to view the compile command
First we should look at the server time,
[Email protected] ~]# tar XF bind-9.9.5.tar.gz-----Expand the installation package
[Email protected] ~]# CD bind-9.9.5
[[email protected] bind-9.9.5]# ls--------------into the extract directory to see if the file is completely
Acconfig.h config.h.in COPYRIGHT isc-config.sh.1 make version
ACLOCAL.M4 config.h.win32 Doc Isc-config.sh.docbook makefile.in win32utils
Atffile config.sub docutil isc-config.sh.html mkinstalldirs
Bin config.threads.in FAQ isc-config.sh.in README
Bind.keys Configure Faq.xml Lib Srcid
Changes configure.in history LIBTOOL.M4 Unit
Config.guess contrib install-sh ltmain.sh util
[[email protected] bind-9.9.5]#./configure--help--------------View Help files
[email protected] bind-9.9.5]# less README---------------bind description
Because the DNS service is not running as root, we need to create users and groups first
[Email protected] bind-9.9.5]# Groupadd-r-G named
[Email protected] bind-9.9.5]# Useradd-r-G named-u named
[[email protected] bind-9.9.5]# ID named
uid=53 (named) gid=53 (named) groups=53 (named)
3, compile
[[email protected] bind-9.9.5]#./configure--prefix=/usr/local/bind9--sysconfdir=/etc/named/ --enable-threads--disable-chroot--disable-ipv6
command explanation:
--prefix=/usr/local/bind9------------- Specify the installation path
--sysconfdir=/etc/named/---------------store all profiles
-- Enable-threads----------enable threads to improve DNS performance
--disable-chroot--disable-ipv6--------Some applications not enabled according to their own needs, Find yourself in the Help information
(1) Modify the PATH environment variable
compile with the new Dig Command
(1)
[[email protected] bind9]#/usr/local/bind9/bin/dig-v-----------The newly compiled version of Dig
dig 9.9.5
[[email Protected] bind9]# dig-v--------------dig version of the original system
dig 9.8.2rc1-redhat-9.8.2-0.17.rc1.el6_4.6
[[email protected] bind9]# vim/etc/profile.d/bind.sh------------in/etc/profile.d/ Create bind.sh Add the following to
export path=/usr/local/bind9/bin:/usr/local/bind9/sbin: $PATH
(2)
Test: Log back in to view
[[email protected] ~]# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/ bind9/bin:/usr/local/bind9/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/nginx/ Sbin:/root/bin
[[email protected] ~]# dig-v
dig 9.9.5
(2) Export help manual
[[email protected] bind9]# man-m share/man/named--------M Specify the path and named to view
[[email protected] bind9]# man named----------------This is not available
no manual entry for Named
[[email protected] bind9]# vim/etc/man.config-------Add to/etc/man.config find
manpath/usr/man
manpath/usr/share/man
manpath/usr/local/man
manpath/usr/local/share/man
manpath/usr/x11r6/man
manpath/usr/local/bind9/ Share/man----------Add this: The path here is the path we just compiled save
[[email protected] bind9]# man Named------can use the
(3) Export of library files and header files-----Compile open use, export library files
[[email Protected] bind9]# vim/etc/ld.so.conf.d/bind9.conf
2, provide the configuration file/etc/named/named.conf
(1) [[email protected] ~]# ls/etc/named-----We see nothing in the named directory, we need to create the configuration file manually
Bind.keys
[Email protected] ~]# vim/etc/named.conf
Options {
Directory "/var/named";
recursion Yes;
};
Zone "." In {-----------------must root parse
Type hint;
File "named.ca";
};
Zone "localhost" in {-------------local resolution
Type master;
File "Localhost.zone";
allow-update {none;};
};
zone "0.0.127.in-addr.arpa" in {---------local reverse parsing
type Master
file "127.0.0.zone";
allow-update {none;};
};
zone "Ning.com" in {---------------Add the fields you want to create
type Master;
file "Ning.com.zone";
Allow-transfer {172.16.0.0/16; 127.0.0.1;};
allow-update {none;};
};
(2) permissions for the profile
[[email protected] named]# chown root:named named.conf------Master configuration file is a primary group
[[email protected] named]# chmod 640 named.conf--------master configuration Permissions
[[email Protected] named]# ll
total 8
-rw-r--r--1 root root 2389 aug 3 11:57 Bind.keys
-rw-r-----1 root named 326 aug 3 12:25 named.conf
(3) Create directory file
[[ Email protected] named]# MKDIR/VAR/NAMED/SLAVES-PV-----Create a directory for var/named/
mkdir:created Directory '/var/named/slaves '
[[email protected] var]# chown root:named/var/named----------Main group
[[email protected] var]# chown named:named/var/named/slaves/----------Main group
[[ Email protected] var]# chmod 750/var/named------Directory permissions (for security only the root user has permission to modify)
[[email Protected] var]# chmod 770/var/named/slaves/------Directory permissions (the store must have write permission from the library configuration file)
3. Create name.ca, create domain Library profile localhost.zone, 127.0.0.zone, Ning.com.zone
(1) Create name.ca,
[[email protected] var]# dig-t NS. @a.root-servers.net > named.ca---Find a server that can sisu the network, generate a, assist to come
[[email protected] named]# ls/var/named-------put it in this directory
named.ca Slaves
(2) Create a domain library configuration file Localhost.zone
[Email protected] named]# vim Localhost.zone
$TTL 86400
@ in SOA localhost. Admin.localhost. (
2014080701
3H
15M
7D
1D)
In NS localhost.
In A 127.0.0.1
(3) Create a domain library profile 127.0.0.zone
[Email protected] named]# vim 127.0.0.zone
$TTL 86400
@ in SOA localhost. Admin.localhost. (
2014080701
3H
15M
7D
1D)
In NS localhost.
1 in PTR localhost.
(4) Create a domain library configuration file Ning.com.zone
[Email protected] named]# vim Ning.com.zone
$TTL 3600
@ in SOA ns.ning.com. Ning.qq.com. (
2014080701
1H
10M
7D
1D)
In NS NS
NS in A 172.16.3.20
www in A 172.16.3.30
(5) Modify the permissions of the library configuration file and belong to the main genus Group
[Email protected] named]# chown:named 127.0.0.zone localhost.zone named.ca ning.com.zone
[Email protected] named]# chmod 640 127.0.0.zone localhost.zone named.ca Ning.com.zone
(6) Checking configuration files and library files
[Email protected] named]# named-checkconf/etc/named/named.conf
[Email protected] named]# named-checkzone "localhost"/var/named/localhost.zone
Zone localhost/in:loaded Serial 2014080701
Ok
[Email protected] named]# named-checkzone "0.0.127.in-addr.arpa"/var/named/127.0.0.zone
Zone 0.0.127.in-addr.arpa/in:loaded Serial 2014080701
Ok
[Email protected] named]# named-checkzone "ning.com" Ning.com.zone
Zone ning.com/in:loaded Serial 2014080701
Ok
4. Try to start the cache name server
[[email protected] named]# named-u named-c/etc/named/nmaed.conf-------We can run the configuration file directly (run in the background)
[[email protected] named]# named-g-u named-c/etc/named/named.conf------G is running in the foreground.
[[email protected] named]# named-u named------Direct start can also
5, provide RNDC
(1) Build and enable
[[email protected] named]# rndc-confgen-r/dev/urandom >/etc/named/rndc.conf------Generate rndc.conf (-R Specify generator, To avoid the absence of random numbers in the entropy pool)
[[email protected] named]# cat/etc/named/rndc.conf Copy the file specified below the generated file to, named.conf and remove the comment.
# Start of Rndc.conf
Key "Rndc-key" {
Algorithm HMAC-MD5;
Secret "lkmcafczusj1k4mm1cmrxg==";
};
Options {
Default-key "Rndc-key";
Default-server 127.0.0.1;
Default-port 953;
};
# End of Rndc.conf
# Use with the following in named.conf, adjusting the Allow list as needed:
# key "Rndc-key" {------------------from here to the place marked below
# algorithm HMAC-MD5;
# algorithm HMAC-MD5;
# secret "+8tpqh0+bgqdh7jvk2w3+w==";
# };
#
# controls {
# inet 127.0.0.1 Port 953
#
#};------------------------here you know, copy this middle content to named.conf and get rid of the annotations. Enable
# End of named.conf
(2) Modify the permissions and the owner of the rndc.conf file, and reread the named Test RNDC command
[[email protected] named] #chmod rndc.conf---------Modify Permissions
[[email protected] named] #chown: named rndc.conf-----------Modify Owner
[[email protected] named]# killall-hup named------------reread configuration file
[[email protected] named]# RNDC reload-----------Test reload configuration file and domain library information
Server Reload Successful
[[email protected] named]# RNDC stautes------------Test View status
6. Provide a required domain
We have added above, the domain name for ning.com, this everyone should understand,, hehe, I just added on the above,,
You can not add it above, after testing the cache name server, here to add testing on the line.
7. Provide startup script:
[[Email protected] named]# service named start-----------but it cannot be started properly with services
Named:unrecognized Service
Startup script:
#!/bin/bash
#
# description:named Daemon
# Chkconfig:-25 80
#
Pidfile=/usr/local/bind9/var/run/named.pid
Lockfile=/var/lock/subsys/named
Conffile=/etc/named/named.conf
[-r/etc/rc.d/init.d/functions] &&. /etc/rc.d/init.d/functions
Start () {
If [-e $lockFile]; Then
echo "named is already running ..."
Exit 0
Fi
Echo-n "Starting named:"
Daemon--pidfile "$pidFile"/usr/local/bind9/sbin/named-u named-c "$confFile"
Retval=$?
Echo
If [$RETVAL-eq 0]; Then
Touch $lockFile
Return $RETVAL
Else
Rm-f $lockFile $pidFile
Return 1
Fi
}
Stop () {
if [!-e $lockFile]; Then
echo "named is stopped."
# Exit 0
Fi
Echo-n "Stopping named:"
Killproc named
Retval=$?
Echo
If [$RETVAL-eq 0];then
Rm-f $lockFile $pidFile
return 0
Else
echo "cannot stop named."
Failure
Return 1
Fi
}
Restart () {
Stop
Sleep 2
Start
}
Reload () {
Echo-n "Reloading named:"
Killproc Named-hup
#killall-hup named
Retval=$?
Echo
Return $RETVAL
}
Status () {
If pidof named &>/dev/null; Then
Echo-n "named is running ..."
Success
Echo
Else
Echo-n "named is stopped ..."
Success
Echo
Fi
}
Usage () {
echo "usage:named {start|stop|restart|status|reload}"
}
Case $ in
Start
start;;
Stop
stop;;
Restart
restart;;
Status
status;;
Reload
reload;;
*)
Usage
Exit 4
;;
Esac
#chmod +x/etc/rc.d/init.d/named-----To execute permissions on the script.
#chkconfig--add named-----Add named to boot daemon chkconfig
#chkconfig--list named-----View status
# chkconfig named on------------boot automatically
#service named start------can be used here.
[Email protected] named]# service named restart
Stopping named: [OK]
Starting named: [OK]
The library configuration is not yet complete and will follow
This article is from the "struggling People" blog, please be sure to keep this source http://wodemeng.blog.51cto.com/1384120/1537227