关于Ubuntu下搭建DNS服务器

  

  结论:

    /etc/bind/named.conf.local 中  zone"localhost" zone "127.in-addr.arpa" 就是一个最好的例子 前者是正向 后者逆向

  ubuntu下bind9配置说明:        http://wiki.ubuntu.org.cn/Bind9%E5%AE%89%E8%A3%85%E8%AE%BE%E7%BD%AE%E6%8C%87%E5%8D%97

  环境:解析如下域名和IP地址

    www.fadeaway.com    11.11.11.11

    zxs.fadeaway.com    11.11.11.11

    xst.fadeaway.com    11.11.11.12

  工具:bind9

  安装:sudo apt-get install bind9

  配置:1. bind9的配置文件在 /etc/bind/下;named.conf,named.conf.options和named.conf.local是主要的配置文件;

     2. named.conf.options文件中forwarders {}中填的是dns地址,在主dns没有你要找的域名时,向哪递归;

 1 options {
 2     //directory "/var/cache/bind";
 3     directory "/etc/bind";
 4     forwarders {192.168.1.1;};
 5     // If there is a firewall between you and nameservers you want
 6     // to talk to, you may need to fix the firewall to allow multiple
 7     // ports to talk.  See http://www.kb.cert.org/vuls/id/800113
 8 
 9     // If your ISP provided one or more IP addresses for stable 
10     // nameservers, you probably want to use them as forwarders.  
11     // Uncomment the following block, and insert the addresses replacing 
12     // the all-0's placeholder.
13 
14     // forwarders 
15     //{
16     //    8.8.8.8;
17     //    8.8.4.4;
18     //};
19 
20     auth-nxdomain no;    # conform to RFC1035
21     listen-on-v6 { any; };
22 };

 

     3.本次实验只需要更改named.conf.local即可;

  下面是named.conf.local的内容,9-18行是我们要添加的内容,注意{}后面要有“;”

  fadeaway.com是正向的,11.in-addr.arpa是逆向的(可阅读TCP/IP详解-卷一,DNS章)

 1 //
 2 // Do any local configuration here
 3 //
 4 
 5 // Consider adding the 1918 zones here, if they are not used in your
 6 // organization
 7 //include "/etc/bind/zones.rfc1918";
 8 
 9 zone "fadeaway.com" {
10     type master;
11     file "/etc/bind/db.fadeaway.com";
12 };
13 
14 
15 zone "11.in-addr.arpa" {
16     type master;
17     file "/etc/bind/db.11";
18 };

    4.下面需要在/etc/bind/下建立两个文件,db.fadeaway.com和db.11;

     文件名和named.conf.local对应;

db.fadeaway.com

 1 $TTL    604800
 2 @    IN    SOA    fadeaway.com. root.fadeaway.com. (
 3                   2        ; Serial
 4              604800        ; Refresh
 5               86400        ; Retry
 6             2419200        ; Expire
 7              604800 )    ; Negative Cache TTL
 8 ;
 9 @    IN    NS    fadeaway.com.
10 @    IN    A    11.11.11.11
11 WWW IN    A    11.11.11.11
12 zxs IN CNAME www
13 xst IN    A    11.11.11.12

db.11

 1 $TTL    604800
 2 @    IN    SOA    fadeaway.com. root.fadeaway.com. (
 3                   1        ; Serial
 4              604800        ; Refresh
 5               86400        ; Retry
 6             2419200        ; Expire
 7              604800 )    ; Negative Cache TTL
 8 ;
 9 @    IN    NS    fadeaway.com.
10 11.11.11    IN    PTR    fadeaway.com.
11 11.11.11    IN    PTR    www.fadeaway.com.
12 12.11.11    IN    PTR    xst.fadeaway.com

    5. sudo /etc/init.d/bind9 restart  重启bind9,加载配置

    6. tail /var/log/syslog  查看系统日志,是否成功运行

    7. 使用nslookup进行检测

     sudo apt-get install nslookup

 1 $ nslookup www.fadeaway.com 10.24.8.148
 2 Server:        10.24.8.148
 3 Address:    10.24.8.148#53
 4 
 5 Name:    www.fadeaway.com
 6 Address: 11.11.11.11
 7 
 8 $ nslookup zxs.fadeaway.com 10.24.8.148
 9 Server:        10.24.8.148
10 Address:    10.24.8.148#53
11 
12 zxs.fadeaway.com    canonical name = www.fadeaway.com.
13 Name:    www.fadeaway.com
14 Address: 11.11.11.11
15 
16 $ nslookup xst.fadeaway.com 10.24.8.148
17 Server:        10.24.8.148
18 Address:    10.24.8.148#53
19 
20 Name:    xst.fadeaway.com
21 Address: 11.11.11.12

 

posted on 2013-04-03 17:50  Z-fadeaway  阅读(1592)  评论(0编辑  收藏  举报