学校的DNS服务器是Linux操作系统,绑定DNS的时候发现总有点问题,常常客户端电脑无法得到正确的解析。于是我就自己研究了下Linux下的绑定域名设置bind软件。
我本地用的是ubuntu 10.04, 使用前更新了下bind软件至最新bind9
bind 使用端口号53来进行通信,包括与其它DNS服务器交换解析信息,所以此商品不能被其它程序占用。
除了使用了多线程、程序代码重构,从而提供了更好的稳定性和安全性,还有其它一些区别:
Apart from being multi-threaded, and a complete code rewrite - which should provide better stability and security in the long term, there are other differences
如果在named.conf文件中有语法错误,BIND9会将它写到日志文件中并且不再重启域名服务器,BIND8会记录日志然后服务死掉。
If there is a syntax error in named.conf, BIND9 will log errors and not reload the named server. BIND8 will log errors and the daemon will die!
取得控制权的TSIGs(shared keys)扩展支持,比如“update-policy"可以取得控制从而动态更新数据。
Extensive support of TSIGs (shared keys) for access control, for example, “update-policy” can be used for fine grained access control of dynamic updates.
启动/停止/重启 工具等,rndc与bind8的ndc不同-不同的通信、授权和特性。
The tool for starting/stopping/reloading etc., rndc is different from the v8 ndc - different communications, authentication and features.
区域配置文件的语法更加严格(比如TTL行必须存在)
Syntax in zone files is more rigorously checked (e.g. a TTL line must exist)
有关named.conf文件的设定
bind8的"check-names"和"statistics-interval"这两项设定没有被移植到bind9中
v8 options ‘check-names’ and ‘statistics-interval’ are not yet implemented in V9.
"auth-nxdomain" 的默认值是"no",如果你没有手动设定这一项,bind9会在启动时生成相应的一条日志消息
the default for the option ‘auth-nxdomain’ is now ‘no’, if you don’t set this manually, BIND 9 logs a corresponding message on startup.
根域名服务器列表,在bind8中的named.root 或 root.hints不需要在BIND9中设定,因为它已经被服务器默认包含了。
The root server list, often called named.root or root.hints in BIND8 is not necessary in BIND 9, as it is included within the server.
在ubuntu中安装bind
sudo apt-get install bind9 dnsutils
配置bind
sudo vi /etc/bind/named.conf.local
修改这个文件,在里面添加下面这些内容:
zone "myqdc.com" {type master;file "/etc/bind/zones/myqdc.com.db";};zone "100.168.192.in-addr.arpa" {type master;file "/etc/bind/zones/rev.100.168.192.in-addr.arpa";};zone "myqdc.com" {type master;file "/etc/bind/zones/myqdc.com.db";};
zone "100.168.192.in-addr.arpa" {type master;file "/etc/bind/zones/rev.100.168.192.in-addr.arpa";};
其中,myqdc.com改为相应的域名,我本地IP地址是192.168.100.100
接着当然需要新建两个文件, myqdc.com.db(用来配置解析记录,比如A,CNAME等), rev.100.168.192.in-addr.arpa(反向解析配置文件)
myqdc.com.db需要放到/etc/bind/zones文件夹下,内容如下:
myqdc.com. IN SOA ns1.myqdc.com. admin.myqdc.com. (
2007031001
28800
3600
604800
38400
)
myqdc.com. IN NS ns1.myqdc.com.
www IN A 221.215.217.101
* IN A 221.215.217.101
@ IN SOA ns1.myqdc.com. admin.myqdc.com. (2007031001;28800;604800;604800;86400)IN NS ns1.myqdc.com.100 IN PTR myqdc.com.
root@ijse-laptop:/etc/bind/zones# nslookup www.myqdc.comServer: 192.168.100.100Address: 192.168.100.100#53Name: www.myqdc.comAddress: 221.215.217.101
root@ijse-laptop:/etc/bind/zones# nslookup bbs.myqdc.comServer: 192.168.100.100Address: 192.168.100.100#53Name: bbs.myqdc.comAddress: 221.215.217.101
root@ijse-laptop:/etc/bind/zones# dig www.myqdc.com; <<>> DiG 9.7.0-P1 <<>> www.myqdc.com;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40293;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1;; QUESTION SECTION:;www.myqdc.com. IN A;; ANSWER SECTION:www.myqdc.com. 38400 IN A 221.215.217.101;; AUTHORITY SECTION:myqdc.com. 38400 IN NS ns1.myqdc.com.;; ADDITIONAL SECTION:ns1.myqdc.com. 38400 IN A 221.215.217.101;; Query time: 0 msec;; SERVER: 192.168.100.100#53(192.168.100.100);; WHEN: Mon Apr 4 11:34:21 2011;; MSG SIZE rcvd: 81