实验:
正向解析
1.[[email protected] etc]# vim /var/named/chroot/etc/named.conf
options {
listen-on port 53 { 172.17.0.142; }; -----修改
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 { any; };
forwarders {8.8.8.8;}; ------转发到指定的dns服务器
recursion yes;
# dnssec-enable yes;
# dnssec-validation yes;
#dnssec-lookaside auto;
2.[[email protected] etc]# vim /var/named/chroot/etc/named.rfc1912.zones
zone "zdj.com" IN { -------添加
type master;
file "zdj.com";
};
3.[[email protected] named]# pwd
/var/named/chroot/var/named
[[email protected] named]# cp named.localhost zdj.com -p
[[email protected] named]# vim zdj.com
$TTL 1D
@ IN SOA dns.zdj.com. root.zdj.com.
(
0 ; serial ----更新序列号
1D ; refresh ----刷新时间
1H ; retry ----重试时间
1W ; expire ----失效时间
3H ) ; minimum ----地址解析记录的最小缓存时间
@ NS dns.zdj.com.
@ MX 6 mail.zdj.com
dns A 172.17.0.142
www A 172.17.0.88
ftp A 172.17.0.123
mail A 172.17.0.145
4.[[email protected] named]# service named restart
5.[[email protected] named]# nslookup www.zdj.com -----测试
Server: 172.17.0.142
Address: 172.17.0.142#53
Name: www.zdj.com
Address: 172.17.0.88
-------测试之前要将dns指向本机ip-------
[[email protected] named]# vim /etc/resolv.conf
nameserver 172.17.0.142
反向解析----两个地方不一样
[[email protected] etc]# vim /var/named/chroot/etc/named.rfc1912.zones
zone "0.17.172.in-addr.arpa" IN { ----添加网段
type master;
file "172.17.0.zone";
};
[[email protected] named]# vim 172.17.0.zone
$TTL 1D
@ IN SOA dns.zdj.com. root.zdj.com.
(
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS dns.zdj.com.
142 PTR dns.zdj.com.
123 PTR ftp.zdj.com.
DNS排错办法:1.看日志 tail -f /var/log/messages
2.检查文件有没有错
[[email protected] etc]# named-checkconf -t /var/named/chroot/
/etc/named.rfc1912.zones:27: missing ‘;‘ before ‘file‘
[[email protected] named]# named-checkzone feng.com feng.com.zone
dns_rdata_fromtext: feng.com.zone:15: near ‘mail2.feng.com.‘: not a valid number
feng.com.zone:19: unknown RR type ‘CNAMEabc‘
zone feng.com/IN: loading from master file feng.com.zone failed: not a valid number
zone feng.com/IN: not loaded due to errors.
[[email protected] named]# named-checkzone feng.com feng.com.zone
zone feng.com/IN: loaded serial 0
OK