1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | [root@stu2~]# yum -y install bind 查看生成了那些配置文件 [root@stu2~]# rpm -qc bind /etc/logrotate.d/named /etc/named.conf //主配置文件 /etc/named.iscdlv.key /etc/named.rfc1912.zones //区域配置文件 /etc/named.root.key /etc/rndc.conf /etc/rndc.key /etc/sysconfig/named / var /named/named.ca / var /named/named.empty / var /named/named.localhost / var /named/named.loopback |
1 2 3 4 5 6 7 8 9 | [root@stu2named]# rpm -ql bind-utils /usr/bin/dig //测试命令工具 /usr/bin/host //host测试命令工具 /usr/bin/nslookup //nslookup测试命令工具 /usr/bin/nsupdate /usr/share/man/man1/dig. 1 .gz /usr/share/man/man1/host. 1 .gz /usr/share/man/man1/nslookup. 1 .gz /usr/share/man/man1/nsupdate. 1 .gz |
1 2 3 4 5 6 7 8 9 10 11 | [root@stu2named]# nslookup //测试工具命令 >server 172.16 . 0.1 //指向能为你解析域名服务器的IP地址(一般为运营商的IP地址) Defaultserver: 172.16 . 0.1 Address: 172.16 . 0.1 # 53 > set q=A //用set设置q指定类型为A记录,然后输入FQDN >www.bai.com Server: 172.16 . 0.1 Address: 172.16 . 0.1 # 53 Non-authoritativeanswer: Name: www.bai.com Address: 221.5 . 71.29 //解析到的结果#172 |
1 2 3 4 5 6 7 8 9 10 | zone "magedu.com" IN { //zone关键字添加正向区域解析库文件
type master; //指定类型
file "magedu.com.zone" ; //指定区域文件名,是相对于/var/named路径,这里的相对路径是根据主配置文件里面的directory关键字定义的
allow-transfer { 172.16 . 2.16 ; }; //指定slave服务器的Ip,可以指定多个 }; zone "10.16.172.in-addr.arpa" IN { //zone关键字添加一个反向解析库文件
type master;
file "172.16.10.zone" ;
allow-transfer { 172.16 . 2.16 ; }; }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | options{ // listen-on port 53 { 127.0.0.1; }; // listen-on-v6 port 53 { ::1; };
directory "/var/named" ;
dump-file "/var/named/data/cache_dump.db" ;
statistics-file "/var/named/data/named_stats.txt" ;
memstatistics-file "/var/named/data/named_mem_stats.txt" ; // allow-query { localhost; };
recursion yes; logging{
channel default_debug {
file "data/named.run" ;
severity dynamic ;
}; }; zone "." IN {
type hint;
file "named.ca" ; }; include "/etc/named.rfc1912.zones" ; //include"/etc/named.root.key"; 用//表示注释掉这几行 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | zone "dep1.magedu.com" IN {
type master;
file "dep1.magedu.com.zone" ; }; $TTL600 @ IN SOA dns.dep1.magedu.com. admin.dep1.magedu.com. (
20130813
2H
10M
7D
2D )
IN NS dns
IN MX 10 mail dns IN A 172.16 . 251.253 mail IN A 172.16 . 251.6 www IN A 172.16 . 251.6 www IN A 172.16 . 251.8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | [root@stu2named]# dig -t A www.dep1.magedu.com ;<<>> DiG 9.8 .2rc1-RedHat- 9.8 . 2 - 0.17 .rc1.el6 <<>> -t Awww.dep1.magedu.com ;;global options: +cmd ;;Got answer: ;;->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43341 ;;flags: qr rd ra; QUERY: 1 , ANSWER: 2 , AUTHORITY: 1 , ADDITIONAL: 1 ;;QUESTION SECTION: ;www.dep1.magedu.com. IN A ;;ANSWER SECTION: www.dep1.magedu.com. 600 IN A 172.16 . 251.8 www.dep1.magedu.com. 600 IN A 172.16 . 251.6 ;;AUTHORITY SECTION: dep1.magedu.com. 536 IN NS dns.dep1.magedu.com. ;;ADDITIONAL SECTION: dns.dep1.magedu.com. 536 IN A 172.16 . 251.253 ;;Query time: 6 msec ;;SERVER: 172.16 . 10.8 # 53 ( 172.16 . 10.8 ) ;;WHEN: Thu Aug 15 17 : 54 : 40 2013 ;;MSG SIZE rcvd: 103 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | options { // listen-on port 53 { 127.0.0.1; }; // listen-on-v6 port 53 { ::1; };
directory "/var/named" ;
dump-file "/var/named/data/cache_dump.db" ;
statistics-file "/var/named/data/named_stats.txt" ;
memstatistics-file "/var/named/data/named_mem_stats.txt" ; // allow-query { localhost; };
recursion yes;
forward only; //只允许转发
forwarders { 172.16 . 0.1 ; }; //转发到能解析的服务上 // dnssec-enable yes; //关于安全的文件都注释掉 // dnssec-validation yes; // dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key" ;
managed-keys-directory "/var/named/dynamic" ; }; logging {
channel default_debug {
file "data/named.run" ;
severity dynamic ;
}; }; |