options { listen-on port 53 { any; }; 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"; forwarders { 8.8.8.8; 202.106.0.20; }; // Those options should be used carefully because they disable port // randomization // query-source port 53; // query-source-v6 port 53; allow-query { any; }; allow-query-cache { any; }; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; view localhost_resolver { match-clients { any; }; match-destinations { any; }; recursion yes; include "/etc/named.rfc1912.zones"; };
04、编辑vi named.rfc1912.zones 如果是主DNS:
1 2 3 4 5 6 7 8 9 10
zone "abc.com" { type master; file "abc.com.zone"; allow-transfer{192.168.1.2;}; }; zone "33.22.11.in-addr.arpa" { type master; file "11.22.33.rev"; allow-transfer{192.168.1.2;}; };
如果是辅DNS:
1 2 3 4 5 6 7 8 9 10
zone "abc.com" { type slave; file "abc.com.zone"; Masters{192.168.1.1;}; }; zone "33.22.11.in-addr.arpa" { type slave; file "11.22.33.rev"; Masters{192.168.1.1;}; };
05、编辑上面配置文件中提到的abc.com.zone文件
1 2 3 4 5 6 7 8 9 10 11 12 13
cd /var/named/chroot/var/named vi abc.com.zone $TTL 86400 @ IN SOA localhost. root.localhost. ( 20110312 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum $ORIGIN abc.com. IN NS dns.abc.com. dns IN A 192.168.1.1 www IN A 192.168.1.1
06、启动服务
1
service named start
07、将服务设置为开机自启
1 2 3 4 5
[root@test ~]chkconfig --list named named 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@test ~]chkconfig --level 345 named on [root@test ~]chkconfig --list named named 0:off 1:off 2:off 3:on 4:on 5:on 6:off