RHEL DNS 配置教程
To : xx
注:本机IP为118.229.139.68
1.安装以下包
bind-libs-9.3.6-4.P1.el5 bind-9.3.6-4.P1.el5 bind-utils-9.3.6-4.P1.el5 bind-chroot-9.3.6-4.P1.el5 caching-nameserver-9.3.6-4.P1.el5
使用rpm -qa|grep bind-命令查询
[root@pcbake ~]# rpm -qa |grep bind- bind-libs-9.3.6-4.P1.el5 bind-9.3.6-4.P1.el5 bind-utils-9.3.6-4.P1.el5 bind-chroot-9.3.6-4.P1.el5 ypbind-1.19-12.el5 [root@pcbake ~]# rpm -qa|grep cach libXfontcache-1.0.2-3.1 libXfontcache-devel-1.0.2-3.1 distcache-1.4.5-14.1 caching-nameserver-9.3.6-4.P1.el5
2.编辑named.conf文件
[root@pcbake etc]# pwd /var/named/chroot/etc listen-on port 53 { 118.229.139.68; };//这里改本机IP allow-query { any; };//此两处改成any match-clients { any; };
3.编辑/etc/named.rfc112.zones文件
添加两个zone
zone "yangyh123.com" IN{ type master; file "yangyh123.com.zone"; allow-update { none; }; }; zone "139.229.118.in-addr.arpa" IN{ type master; file "yangyh123.com.rev"; allow-update { none; }; };
4.新建yangyh123.com.rev,yangyh123.com.zone两个文件,内容如下
[root@pcbake named]# pwd
/var/named/chroot/var/named
[root@pcbake named]# ls
data named.broadcast named.local yangyh123.com.rev
localdomain.zone named.ca named.zero yangyh123.com.zone
localhost.zone named.ip6.local slaves
[root@pcbake named]#
[root@pcbake named]# cat yangyh123.com.rev
$TTL 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS yangyh123.com.
68 IN PTR www.yangyh123.com.
[root@pcbake named]#
[root@pcbake named]# cat yangyh123.com.zone $TTL 86400 @ IN SOA localhost. root.localhost. ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS localhost yangyh123.com. IN A 118.229.139.43 www.yangyh123.com. IN A 118.229.139.43 mail.yangyh123.com. IN A 118.229.139.43 [root@pcbake named]#
5. named-checkzone
[root@pcbake named]# named-checkzone usage: named-checkzone [-djqvD] [-c class] [-o output] [-t directory] [-w directory] [-k (ignore|warn|fail)] [-n (ignore|warn|fail)] zonename filename [root@pcbake named]# named-checkzone yangyh123.com /var/named/chroot/var/named/yangyh123.com.zone zone yangyh123.com/IN: loaded serial 42 OK [root@pcbake named]# named-checkzone 139.229.118.in-addr.arpa /var/named/chroot/var/named/yangyh123.com.rev zone 139.229.118.in-addr.arpa/IN: loaded serial 1997022700 OK [root@pcbake named]#
6.更改/etc/resolv.conf,注意要本机IP在前…
[root@pcbake named]# cat /etc/resolv.conf
; generated by /sbin/dhclient-script
;search bupt.edu.cn
;nameserver 211.68.71.4
nameserver 118.229.139.68
nameserver 211.68.71.5
[root@pcbake named]#
7.运行service named restart
[root@pcbake named]# lsof -i:53 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME dnsmasq 4281 nobody 6u IPv4 12980 TCP 192.168.122.1:domain (LISTEN) dnsmasq 4281 nobody 7u IPv4 12981 UDP 192.168.122.1:domain named 12937 named 20u IPv6 66378 TCP localhost6.localdomain6:domain (LISTEN) named 12937 named 21u IPv4 66380 TCP www.yangyh123.com:domain (LISTEN) named 12937 named 512u IPv6 66377 UDP localhost6.localdomain6:domain named 12937 named 513u IPv4 66379 UDP www.yangyh123.com:domain [root@pcbake named]#
8.测试
[root@pcbake named]# nslookup www.yangyh123.com Server: 118.229.139.68 Address: 118.229.139.68#53 Name: www.yangyh123.com Address: 118.229.139.43 [root@pcbake named]# nslookup yangyh123.com Server: 118.229.139.68 Address: 118.229.139.68#53 Name: yangyh123.com Address: 118.229.139.43 [root@pcbake named]# nslookup mail.yangyh123.com Server: 118.229.139.68 Address: 118.229.139.68#53 Name: mail.yangyh123.com Address: 118.229.139.43 [root@pcbake named]#
[root@pcbake named]# nslookup 118.229.139.68
Server: 118.229.139.68
Address: 118.229.139.68#53
68.139.229.118.in-addr.arpa name = www.yangyh123.com.
[root@pcbake named]#
[root@pcbake named]# nslookup baidu.com ;; Got SERVFAIL reply from 118.229.139.68, trying next server Server: 211.68.71.5 Address: 211.68.71.5#53 Non-authoritative answer: Name: baidu.com Address: 123.125.114.144 Name: baidu.com Address: 220.181.111.85 Name: baidu.com Address: 220.181.111.86 [root@pcbake named]#
躲猫猫社团团长 http://t.sina.com.cn/coolria