1.添加named用户和用户组 groupadd -r named useradd -r -M -s /bin/nologin -g named named 2.编译安装(提前安装gcc) tar xf bind-9.9.2.tar.gz cd bind-9.9.2 ./configure --prefix=/usr/local/bind98 --enable-threads --enable-epoll --disable-chroot 3.建立配置文件/usr/local/bind98/etc/named/named.conf vim /usr/local/bind98/etc/named/named.conf #定义全局的 options { #定义named的固定工作路径 directory "/var/named"; }; #定义根的区域 zone "." IN { type hint; #类型、hint表示为根的 file "named.ca"; #指定的文件 }; #定义本本地的区域 zone "localhost" IN { type master; #类型属于master、属于自己的 file "named.localhost"; #指定的文件 allow-transfer { none; }; #不允许任何人传送的 }; #定义反向解析的 zone "0.0.127.in-addr.arpa" IN { type master; #类型属于master、属于自己的 file "named.loopback"; #指定的文件 allow-transfer { none; };#不允许任何人传送的 }; zone "cache.com" IN { #测试域cache.com type master; file "cache.com.zone"; }; 4.建立需要的named文件 name.ca文件内容: [root@make named]# cat named.ca ; This file holds the information on root name servers needed to ; initialize cache of Internet domain name servers ; (e.g. reference this file in the "cache . <file>" ; configuration file of BIND domain name servers). ; ; This file is made available by InterNIC ; under anonymous FTP as ; file /domain/named.cache ; on server FTP.INTERNIC.NET ; -OR- RS.INTERNIC.NET ; ; last update: November 05, 2014 ; related version of root zone: 2014110501 ; ; formerly NS.INTERNIC.NET ; . 3600000 NS A.ROOT-SERVERS.NET. A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4 A.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:ba3e::2:30 ; ; FORMERLY NS1.ISI.EDU ; . 3600000 NS B.ROOT-SERVERS.NET. B.ROOT-SERVERS.NET. 3600000 A 192.228.79.201 B.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:84::b ; ; FORMERLY C.PSI.NET ; . 3600000 NS C.ROOT-SERVERS.NET. C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12 C.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2::c ; ; FORMERLY TERP.UMD.EDU ; . 3600000 NS D.ROOT-SERVERS.NET. D.ROOT-SERVERS.NET. 3600000 A 199.7.91.13 D.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2d::d ; ; FORMERLY NS.NASA.GOV ; . 3600000 NS E.ROOT-SERVERS.NET. E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10 ; ; FORMERLY NS.ISC.ORG ; . 3600000 NS F.ROOT-SERVERS.NET. F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241 F.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2f::f ; ; FORMERLY NS.NIC.DDN.MIL ; . 3600000 NS G.ROOT-SERVERS.NET. G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4 ; ; FORMERLY AOS.ARL.ARMY.MIL ; . 3600000 NS H.ROOT-SERVERS.NET. H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53 H.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:1::803f:235 ; ; FORMERLY NIC.NORDU.NET ; . 3600000 NS I.ROOT-SERVERS.NET. I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17 I.ROOT-SERVERS.NET. 3600000 AAAA 2001:7fe::53 ; ; OPERATED BY VERISIGN, INC. ; . 3600000 NS J.ROOT-SERVERS.NET. J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30 J.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:c27::2:30 ; ; OPERATED BY RIPE NCC ; . 3600000 NS K.ROOT-SERVERS.NET. K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129 K.ROOT-SERVERS.NET. 3600000 AAAA 2001:7fd::1 ; ; OPERATED BY ICANN ; . 3600000 NS L.ROOT-SERVERS.NET. L.ROOT-SERVERS.NET. 3600000 A 199.7.83.42 L.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:3::42 ; ; OPERATED BY WIDE ; . 3600000 NS M.ROOT-SERVERS.NET. M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33 M.ROOT-SERVERS.NET. 3600000 AAAA 2001:dc3::35 ; End of file named.localhost文件内容 [root@make named]# cat named.localhost $TTL 86400 ;定义宏 @ IN SOA localhost admin.localhost. ( 2014031101 ;序列号 2H ;刷新时间 10M ;失败时重试间隔时间 7D ;过期时间 1D) ;否定答案的时间 IN NS localhost. localhost. IN A 172.0.0.1 named.lookup文件内容 [root@make named]# cat named.loopback $TTL 86400 @ IN SOA localhost admin.localhost. ( 2014031101 2H 10M 7D 1D ) IN NS localhost. 1 IN PTR localhost. cache.com.zone文件内容 $TTL 86400 ;定义宏 @ IN SOA localhost admin.localhost. ( 2014031101 ;序列号 2H ;刷新时间 10M ;失败时重试间隔时间 7D ;过期时间 1D) ;否定答案的时间 IN NS localhost. localhost. IN A 172.0.0.1 www.cache.com. IN A 192.168.100.100 5.启动脚本(自己编写,比较拙劣) [root@make named]# cat /etc/init.d/named #!/bin/bash # named a network name service. # chkconfig: 345 35 75 # description: a name server pidfile='/var/named/named.pid' 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 /usr/local/bind98/sbin/named ]; then /usr/local/bind98/sbin/named -c /usr/local/bind98/etc/named/named.conf -u named && ps -aef | grep 'named'|awk '{print $2}' > $pidfile && echo . && echo 'BIND9 server started' fi ;; stop) if [ -e $pidfile ];then namedpid=`cat $pidfile` for i in $namedpid;do kill -9 $i 2> /dev/null done rm $pidfile && echo . && echo 'BIND9 server stopped' fi ;; restart) echo . echo "Restart BIND9 server" $0 stop sleep 10 $0 start ;; reload) /usr/local/named/sbin/rndc reload ;; status) /usr/local/named/sbin/rndc status ;; *) echo "$0 start | stop | restart |reload |status" ;; esac 6.测试环境 [root@make named]# dig -t A www.cache.com @127.0.0.1 ; <<>> DiG 9.9.2 <<>> -t A www.cache.com @127.0.0.1 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32980 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;www.cache.com. IN A ;; ANSWER SECTION: www.cache.com. 86400 IN A 192.168.100.100 ;; AUTHORITY SECTION: cache.com. 86400 IN NS localhost. ;; ADDITIONAL SECTION: localhost. 86400 IN A 172.0.0.1 ;; Query time: 13 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Mon May 4 04:17:50 2015 ;; MSG SIZE rcvd: 97
DNS之一:编译安装
原创
©著作权归作者所有:来自51CTO博客作者anka0501的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
DNS之编译安装
DNS编译安装
DNS