Bind是使用最广泛的域名服务器,由berkeleyinternetnamedomainservice的缩写伯克利大学编写。 在Debian Stretch 9.3中,最新版本为Bind 9.10.5。
Bind的安装比较简单,使用以下命令即可。
apt-get安装绑定9
apt-getinstallbind9- hostdnsutils
apt-get安装绑定9-doc
要设置绑定,请执行以下操作:
1、域名解析
这里,将debian.cn解析为192.168.10.2的例子设为:
cd/etc/bind
vimnamed.conf.local
添加前向分析和反向分析区域(zone ) :
zone'debian.cn'{
类型主程序;
file'/etc/bind/db.debian.cn ';
(;
zone'168.192.in-addr.arpa'{
类型主程序;
file'/etc/bind/db.192.168 ';
(;
1.1正向分析: db.debian.cn内容如下:
$TTL 604800
@ insoadebian.cn.admin.debian.cn.(请参阅
2; 串行通信
604800; 刷新
86400; 恢复
2419200; Expire
604800; Negative Cache TTL
;
@ IN NS ns.debian.cn。
@ IN A 192.168.10.2
ns IN A 192.168.10.2
www IN CNAME @
ftp IN CNAME @
proxy IN CNAME @
blog IN CNAME @
mysql IN CNAME @
* IN A 192.168.10.2
在此指定域debian.cn的许可证DNS服务器,ns.debian.cn .是本地的。 这是因为后续的前向解析记录(即a记录)将ns指向本地IP地址192.168.10.2。
另外,还添加了一些指向debian.cn的CNAME别名记录。
最后添加通用分析支持时,对*.debian.cn的所有请求都将分析为192.168.10.2。
1.2反向分析: db.192.168内容如下。
$TTL 604800
@ insoadebian.cn.admin.debian.cn.(请参阅
1; 串行通信
604800; 刷新
86400; 恢复
2419200; Expire
604800; Negative Cache TTL
;
@ IN NS ns.debian.cn。
2.1IN PTR debian.cn。
这里的逆分析很简单,就是将192.168.10.2指向debian.cn
2 .配置缓存dns服务器
vimnamed.conf.options
移除其中的几个注释符号(/),并添加您网络的ISP (互联网信息服务提供商)的DNS。 最后内容如下。
选项{
目录'/qxdxtg/cache/bind ';
//ifthereisafirewallbetweenyouandnameserversyouwant
//to talk to,youmayneedtofixthefirewalltoallowmultiple
//portstotalk.see http://www.kb.cert.org/vuls/id/800113
//ifyourispprovidedoneormoreipaddressesforstable
//nameservers,youprobablywanttousethemasforwarders。
//Uncomment the following block,and insert the addresses replacing
//the all-0's placeholder。
前锋队{
114.114.114.114;
61.139.2.69;
(;
auth-nxdomain no; # conform to RFC1035
listen-on-v6{any; (;
(;
重新启动BIND服务
命令使用sudo systemctl restart bind9或sudorndc reload
测试BIND分析是否正常
使用测试命令,确认百度主站是否能正确解析,
dig www.baidu.com @192.168.10.2
注意@192.168.10.2目的是指定要使用的域名服务器。 由于上面在resolv.conf中将本机使用的DNS服务器指定为192.168.10.2,因此这里@192.168.10.2不是必需的。
配置到此结束。 更多信息说明请仔细阅读Debian官网的Bind9页。