3.vi /etc/named.conf 默认用六个配置。 我们复制 zone"localhsot" IN { type master; file "localhost.zone"; allow-update {nane; }; }; zone "0.0.127.in-addr.arpa" IN { type master; file "localhost.zone"; allow-update {none; }; };
粘贴到下面,修改一下域名和区域。
zone "xapc.com" IN { type master; file "xapc.com.zone"; allow-update {none; }; }; zone "13.168.192.in-addr.arpa" IN { type master; file "xapc.com.rev"; allow-update {none;}; };
:wq
4.#clear 5.#cd /var/named 6.#ll 7.#cp localhost.zone xapc.com.zone 8.#cp named.local xapc.com.rev 9.#vi xapc.com.zone --我们要修改里面的配置了 @ IN SOA root ( 42 ; serial(d.adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS @ IN A 172.0.0.1 IN AAAA ::1 ---------------这是系统默认的配置。我们要修改了 @ IN SOA dns1.xapc.com. root.xapc.com. ( 42 ; serial(d.adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS dns1.xapc.com. IN NS dns2.xapc.com. IN MX 5 mail.xapc.com. dns1 IN A 192.168.13.1 dns2 IN A 192.168.13.2 www IN CNAME dns1.xapc.com. ftp IN CNAME dns2.xapc.com. mail IN CNAME dns2.xapc.com.
:wq
10.#vi xapc.com.rev @ IN SOA localhost.root.localhost. ( 132323232 ; Serial 28808 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Mimimum IN NS localhost. 1 IN PTR localhost. -----------以上是默认的配置,我们要修改了 @ IN SOA dns1.xapc.com root.xapc.com. ( 132323232 ; Serial 28808 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Mimimum IN NS dns1.xapc.com. IN NS dns2.xapc.com.
1 IN PTR dns1.xapc.com. 1 IN PTR www.xapc.com. 2 IN PTR dns2.xapc.com. 2 IN PTR ftp.xapc.com. :wq 11.# named-checkconf --如果没有提示说明成功了 12.# named-checkzone xapc.com xapc.com.zone 13.#service named restart
zone"localhsot" IN { type master; file "localhost.zone"; allow-update {nane; }; }; zone "0.0.127.in-addr.arpa" IN { type master; file "localhost.zone"; allow-update {none; }; }; -----这是它默认的配置,我们要添加配置内容。 zone "xapc.com" IN { type slave; file "slaves/xapc.com.zone"; masters {192.168.13.1; }; }; zone "13.168.192.in-addr.arpa" IN { type slave; file "slaves/xapc.com.rev"; masters {192.168.13.1;}; }; :wq
9.#ll /var/named/ --可以看到九个文件 10.#ll /var/named/slaves/ total 0 11.#service named start 12.#ll /var/named/slaves -rw---- 1 named named 436 xapc.com.rev -rw---- 1 named named 424 xapc.com.zone 13.#nslookup ftp.xapc.com Server: 192.168.13.2 Address: 192.168.13.2#53
ftp.xapc.com canonical name = dns2.xapc.com. Name: dns2.xapc.com Address: 192.168.13.2
zone "xapc.com" IN { type slave; file "slaves/xapc.com.zone"; masters {192.168.13.1; }; }; zone "13.168.192.in-addr.arpa" IN { type slave; file "slaves/xapc.com.rev"; masters {192.168.13.1;}; }; ---- 这是前面配置好的结果,我们现在要在添加配置。
zone "pcgj.com" IN { type master; file "pcgj.com.zone"; allow-update {none; }; }; :wq
2.# cd /var/named 3.#ll 4.#cp localhost.zone pcgj.com.zone 5.#vi pcgj.com.zone @ IN SOA @ root ( 42 ; serial(d.adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS @ IN A 172.0.0.1 IN AAAA ::1 ---------------这是系统默认的配置。我们要修改了 @ IN SOA dns.pcgj.com. root.pcgj.com.( 42 ; serial(d.adams) 3H ; refresh 15W ; retry 1W ; expiry 1D ) ; minimum IN NS dns.pcgj.com. dns IN A 192.168.13.2
:wq
6.#service named restart 7.#nslookup dns.pcgj.com Server: 192.168.13.2 Address: 192.168.13.2#53
好了 下面我们在讲一个重要的内容。 DNS子域的委派。 这两台服务器是父子关系。但两个人各有各得dns服务器来解析。 好了,我们现在从辅助dns上开始吧。 1:#pwd /var/named 2: #vi /etc/named.conf zone "0.in-addr.arpa" IN { type master; file"named.zero"; allow-update{none; }; }; zone "pcgj.com" IN { type master; file "pcgj.com.zone"; allow-update {none; }; }; zone "xapc.com" IN { type forward; forward only; forwarders {192.168.13.1; }; };
----上面是前面修改好的我们要删除一些配置, 下面在添加一些内容。 zone "ca.xapc.com" IN { type master; file "ca.xapc.com.zone"; ailow-update {none; }; }; :ok 我们还要新建一个ca.xapc.com.zone文件
2.#ll 3.#cp pcgj.com.zone ca.xapc.com.zone 4.#vi ca.xapc.com.zone @ IN SOA dns.pcgj.com. root.pcgj.com.( 42 ; serial(d.adams) 3H ; refresh 15W ; retry 1W ; expiry 1D ) ; minimum IN NS dns.pcgj.com. dns IN A 192.168.13.2 ----这是前面我们修改好的文件,我们要修改它。 @ IN SOA dns.ca.xapc.com. root.ca.xapc.com.( 42 ; serial(d.adams) 3H ; refresh 15W ; retry 1W ; expiry 1D ) ; minimum
IN NS dns.ca.xapc.com. dns IN A 192.168.13.2 www IN A 192.168.13.1 :wq 5:# service named restart 6:# nslookup www.ca.xapc.com Server: 192.168.13.2 Address: 192.168.13.2#53
7:#nslookup www.ca.xapc.com ---不能解析的,因为没有做委派,所以不能解析。 8:#vi /etc/named.conf 做委派是时候不需要修改主配置文件。 我们只需要修改xapc.com.zone这个住配置文件就好了 9:#vi xapc.com.zone @ IN SOA dns1.xapc.com. root.xapc.com. ( 42 ; serial(d.adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS dns1.xapc.com. IN NS dns2.xapc.com. IN MX 5 mail.xapc.com. dns1 IN A 192.168.13.1 dns2 IN A 192.168.13.2 www IN CNAME dns1.xapc.com. ftp IN CNAME dns2.xapc.com. mail IN CNAME dns2.xapc.com. -------这是前面我们修改好的, 我们还要修改此文件。
@ IN SOA dns1.xapc.com. root.xpac.com.( 42 ; serial(d.adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS dns.ca.xapc.com. IN NS dns1.xapc.com. IN NS dns2.xapc.com. IN MX 5 mail.xapc.com. dns1 IN A 192.168.13.1 dns2 IN A 192.168.13.2 www IN CNAME dns1.xapc.com. ftp IN CNAME dns2.xapc.com. mail IN CNAME dns2.xapc.com. dns.ca IN A 192.168.13.2
:wq
10:#services named restart 11:#nslookup www.ca.xapc.com Server: 192.168.13.1 Address: 192.168.13.1#53