3.
[root@centos6 named]# vi example.com.zone
正向文件内容如下:
1. [root@centos6 named]# cat example.com.zone 2. $TTL 86400
3. @ IN SOA dns.example.com. root.example.com. ( 4. 2011091200 ; serial 5. 3H ; refresh 6. 1H ; retry 7. 1W ; expire 8. 0) ; minimum 9.
10. @ IN NS dns.example.com. 11.
12. dns IN A 192.168.48.10 13.
14. www IN A 192.168.48.10
如下图所示
添加反向文件:
1. 2.
[root@centos6 named]# touch 192.168.48.zone [root@centos6 named]# vi 192.168.48.zone
反向文件内容如下:
1. 2. 3. 4. 5. 6. 7. 8. 9.
[root@centos6 named]# cat 192.168.48.zone $TTL 86400
@ IN SOA dns.example.com. root.example.com. ( 2011091200 ; serial 3H ; refresh 1H ; retry 1W ; expire 0) ; minimum
10. @ IN NS dns.example.com.
11. 10.48.168.192.in-addr.arpa. IN PTR dns.example.com. 12. 6 IN PTR www.example.com.
如下图所示
13.
6. 检查正向文件和反向文件配置是否有误
[python] view plain copy 1. 2. 3. 4. 5. 6. 7.
[root@centos6 named]# named-checkzone 192.168.48.zone /var/named/chroot/var/named/192.168.48.zone
/var/named/chroot/var/named/192.168.48.zone:10: ignoring out-of-zone data (10.48.168.192.in-addr.arpa)
zone 192.168.48.zone/IN: loaded serial 2011091200 OK
[root@centos6 named]# named-checkzone example.com /var/named/chroot/var/named/example.com.zone
zone example.com/IN: loaded serial 2011091200 OK
ok即为文件配置正确
7. 修改正向文件与反向文件所属组
1. 2.
[root@centos6 named]# chgrp named /var/named/chroot/var/named/192.168.48.zone
[root@centos6 named]# chgrp named /var/named/chroot/var/named/example.com.zone
8. 网络配置
配置虚拟机的IP地址,可以使用system-config-network-tui的命令配置,或者直接更改网卡的配置文件/etc/sysconfig/network-scripts/ifcfg-eth0
此处使用修改配置文件的方法更改IP地址,DNS虚拟机的IP地址配置为192.168.0.222,如下所示: DEVICE=eth0 TYPE=Ethernet ONBOOT=yes
NM_CONTROLLED=yes BOOTPROTO=none IPADDR=192.168.0.222 PREFIX=24
GATEWAY=192.168.0.1 DNS1=192.168.0.222 DEFROUTE=yes
IPV4_FAILURE_FATAL=yes IPV6INIT=no
NAME=\
保存退出后,使用service network restart命令重启网络服务 service network restart
修改主机名,编辑文件/etc/sysconfig/network为DNS vi /etc/sysconfig/network 修改HOSTNAME=DNS
使用cat命令查看一下配置文件
使用命令hostname DNS更改显示的主机名后,退出重新登录即可 hostname DNS
修改/etc/hosts文件 vi /etc/hosts
添加一行
192.168.0.222 DNS
使用cat命令查看/etc/hosts文件
9. 测试dns服务能否正常开启
1. 2. 3. 4. 5. 6. 7.
[root@centos6 named]# service named status
rndc: neither /etc/rndc.conf nor /etc/rndc.key was found named is stopped
[root@centos6 named]# service named start Generating /etc/rndc.key:[ OK ] Starting named: [ OK ]
[root@centos6 named]# nslookup 192.168.1.24 (反向解析测试)
8.
9. 10.48.168.192.in-addr.arpa name = dns.example.com.
10. [root@centos6 named]# nslookup www.example.com (正向解析测试)