b.使用nslookup命令测试 [root@localhost named]# nslookup
> server 127.0.0.1
Default server: 127.0.0.1
Address: 127.0.0.1#53
> set q=A
> localhost
Server:127.0.0.1
Address:127.0.0.1#53
Name:localhost
Address: 127.0.0.1
> set q=NS
> localhost
Server:127.0.0.1
Address:127.0.0.1#53
localhostnameserver = localhost.
>exit
三、配置DNS主域名解析服务器,假设域名是itxingzhe.com
1.打开编辑/etc/named.rfc1912.zones文件,添加如下内容。 [root@localhost etc]# vim /etc/named.rfc1912.zones
zone "itxingzhe.com" IN { //正向解析
type master;
file "named.itxingzhe.com.zone";
allow-update { none; };
};
zone "2.168.192.in-addr.arpa" IN { //反向解析,注意IP写法是反过来的网段。
type master;
file "named.2.168.192.arpa";
allow-update { none; };
};
2.到/var/named目录下创建正/反向解析配置文件。
a.正向解析配置 [root@localhost named]# vim /var/named/named.itxingzhe.com.zone
$TTL 1D
@ IN SOA ns1.itxingzhe.com. root.itxingzhe.com. (
20140625 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS ns1.itxingzhe.com.
IN A 192.168.2.198
www.itxingzhe.com. IN A 192.168.2.198
ftp.itxingzhe.com. IN A 192.168.2.198
//其他的域名一次类推
b.反向解析配置 [root@localhost named]# vim /var/named/named.2.168.192.arpa
$TTL 1D
@ IN SOA ns1.itxingzhe.com. root.itxingzhe.com. (
20140625 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS ns1.itxingzhe.com.
198 IN PTR ns1.itxingzhe.com.
198 IN PTR www.itxingzhe.com.
c.修改配置文件属组为named [root@localhost named]# chown :named /var/named/named.2.168.192.arpa /var/named/named.itxingzhe.com.zone
//这样也可以
[root@localhost named]# chown :named /var/named/named*
3.检查配置文件
参考以上“二、6.检查配置文件”。 [root@localhost named]# named-checkconf
[root@localhost named]# named-checkzone "itxingzhe.com" /var/named/named.itxingzhe.com.zone
zone itxingzhe.com/IN: loaded serial 20140625
OK
[root@localhost named]# named-checkzone "named.2.168.192.arpa" /var/named/named.2.168.192.arpa
zone named.2.168.192.arpa/IN: loaded serial 20140625
OK
4.重启named服务或重新加载配置文件 [root@localhost named]# service named restart
停止 named:. [确定]
启动 named: [确定]
或
[root@localhost named]# /etc/init.d/named reload
重新载入named: [确定]
5.测试DNS
参考以上“二、8.测试DNS”。 [root@localhost named]# dig -t A www.itxingzhe.com @192.168.2.198//测试A记录
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> -t A www.itxingzhe.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62759
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1