bind-9.7.3-8.P3.el6_2.2.i686
bind-libs-9.7.3-8.P3.el6_2.2.i686
bind-sdb-9.7.3-8.P3.el6_2.2.i686
bind-devel-9.7.3-8.P3.el6_2.2.i686
bind-utils-9.7.3-8.P3.el6_2.2.i686
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
listen-on port 53 { any; }; // 开启侦听端口53,接受任意IP连接
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 { 0.0.0.0/0; }; //// 允许任意IP查询这里也可以修改为any如果不修改会在nslookup出现错误refused被拒绝
forward only; //增加转发功能
forwarders {
202.101.172.35; //浙江DNS服务器地址
202.101.172.46;};
dnssec-validation yes;
dnssec-lookaside auto;
bindkeys-file "/etc/named.iscdlv.key";
};
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
type hint;
file "named.ca";
};
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
// and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
// (c)2007 R W Franks
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
acl 定义IP地址的访问控制清单
control 定义ndc使用的控制通道
include 把其他文件包含到配置文件中
key 定义授权的安全密钥
logging 定义日志写什么,写到哪
opitons 定义全局配置选项和缺省值
server 定义远程服务器的特征
trunsted-keys 为服务器定义DNSSEC加密密钥
zone 定义一个区
接下来的 SOA 设置,是被括在“( )”之间的 5 组数字,主要作为和 slave 服务器同步 DNS 资料所使用的资料:
type master;
file "named.localhost";
allow-update { none; };
};
type master;
file "named.localhost";
allow-update { none; };
};
type master;
file "named.loopback";
allow-update { none; };
};
type master;
file "named.loopback";
allow-update { none; };
};
type master;
file "named.empty";
allow-update { none; };
};
type master; //类型为master
file "zh888.com"; //文件名字为zh888.com在/var/named中创建touch一个zh888.com
allow-update { none; };
};
type master;
file "zh888.rev";
allow-update { none; };
};
5.[root@zh888 named]# ls //查看/var/named/目录下的内容:
data dynamic named.ca named.empty named.localhost named.loopback slaves zh888.com zh888.rev
6.[root@zh888 named]# cat zh888.com //查看正向区域文件
$TTL 1D
@ IN SOA zh888.com. root.zh888.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
www IN A 192.168.40.40
mail IN A 192.168.40.40
mail IN MX 10 mail.zh888.com
7.[root@zh888 named]# cat zh888.rev //反向区域
$TTL 86400
@ IN SOA zh888.com. root.zh888.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
@ IN NS zh888.com.
40 IN PTR mail.zh888.com.
40 IN PTR www.zh888.com.
8.[root@zh888 bind]# cat /etc/resolv.conf //设置域名为本机ip
nameserver 192.168.40.40
search zh888.com
9.[root@zh888 bind]# cat /etc/hosts //查看本地hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.40.40 zh888.com zh888
NETWORKING=yes
HOSTNAME=zh888.com
[root@zh888 bind]# service named restart
Stopping named: . [ OK ]
Starting named: [ OK ]
[root@zh888 bind]# nslookup
> www.zh888.com
Server: 192.168.40.40
Address: 192.168.40.40#53
> //出现这个原因为/etc/named.conf
allow-query { 0.0.0.0; } 如果没加/0就会出现上面的拒绝信息或者为any也是可以的。
Stopping named: . [ OK ]
Starting named: [ OK ]
> www.zh888.com
Server: 192.168.40.40
Address: 192.168.40.40#53
Name: www.zh888.com
Address: 192.168.40.40
//成功查询哈哈!
[root@zh888 bind]# nslookup//查看DNS反向区域
> 192.168.40.40
Server: 192.168.40.40
Address: 192.168.40.40#53
40.40.168.192.in-addr.arpa name = mail.zh888.com.
//成功查询。
> set type=MX
> mail.zh888.com
Server: 192.168.40.40
Address: 192.168.40.40#53
> //邮件交换成功
> set type=SOA //查看授权信息
> zh888.com
Server: 192.168.40.40
Address: 192.168.40.40#53
origin = zh888.com
mail addr = root.zh888.com
serial = 0
refresh = 86400
retry = 3600
expire = 604800
minimum = 10800