BIND服务器端程序
主要执行程序:/usr/sbin/named
服务脚本:/etc/init.d/named
默认监听端口:53
主配置文件:/var/named/chroot/etc/named.conf保存DNS解析记录的数据文件位于:/var/named/chroot/var/named/
安装服务
在安装linux 5 装DNS服务的时候发现了如下错误!
[root@localhost Server]# rpm -ivh bind-chroot-9.3.3-7.el5.i386.rpmwarning: bind-chroot-9.3.3-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186error: Failed dependencies: bind = 30:9.3.3-7.el5 is needed by bind-chroot-9.3.3-7.el5.i386
主要是因为缺少了相应的包
在不是完全安装系统软件包的情况,必需要安装的软件包如下:1:util-linux-2.13-0.44.el5.i386.rpm[root@localhost Server]# rpm -ivh util-linux-2.13-0.44.el5.i386.rpmwarning: util-linux-2.13-0.44.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186Preparing... ########################################### [100%] package util-linux-2.13-0.44.el5 is already installed
2:cachefilesd-0.7-6.el5.i386.rpm
[root@localhost Server]# rpm -ivh cachefilesd-0.7-6.el5.i386.rpmwarning: cachefilesd-0.7-6.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186Preparing... ########################################### [100%] 1:cachefilesd ########################################### [100%]
3:bind-9.3.3-7.el5.i386.rpm
[root@localhost Server]# rpm -ivh bind-9.3.3-7.el5.i386.rpmwarning: bind-9.3.3-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186Preparing... ########################################### [100%] 1:bind ########################################### [100%]
4:caching-nameserver-9.3.3-7.el5.i386.rpm
[root@localhost Server]# rpm -ivh caching-nameserver-9.3.3-7.el5.i386.rpmwarning: caching-nameserver-9.3.3-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186Preparing... ########################################### [100%] 1:caching-nameserver ########################################### [100%]
5:bind-chroot-9.3.3-7.el5.i386.rpm
[root@localhost Server]# rpm -ivh bind-chroot-9.3.3-7.el5.i386.rpmwarning: bind-chroot-9.3.3-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186Preparing... ########################################### [100%] package bind-chroot-9.3.3-7.el5 is already installed
启动服务和服务开机启动
1:启动服务
[root@localhost Server]# service named startStarting named: [ OK ]
2:检测服务是否开机启动[root@localhost Server]# chkconfig --list namednamed 0:off 1:off 2:off 3:off 4:off 5:off 6:off
3:服务开机启动[root@localhost Server]# chkconfig named on
创建主配置文件
[root@dnssvr ~]# cp -p /var/named/chroot/etc/named.caching-nameserver.conf /var/named/chroot/etc/named.conf
[root@dnssvr ~]# ls -l /var/named/chroot/etc/总计 40-rw-r--r-- 1 root root 165 05-06 23:54 localtime-rw-r----- 1 root named 1100 2007-01-17 named.caching-nameserver.conf-rw-r----- 1 root named 911 05-29 17:25 named.conf //注意需要保持原有的权限及属主-rw-r----- 1 root named 955 2007-01-17 named.rfc1912.zones-rw-r--r-- 1 root named 113 05-29 15:57 rndc.key[root@dnssvr ~]#
[root@dnssvr ~]# vim /var/named/chroot/etc/named.conf named.conf Provided by Red Hat caching-nameserver package to configure the// ISC BIND named(8) DNS server as a caching only nameserver // (as a localhost DNS resolver only). See /usr/share/doc/bind*/sample/ for example named configuration files. DO NOT EDIT THIS FILE - use system-config-bind or an editor// to create named.conf - edits to this file will be lost on // caching-nameserver package upgrade.//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"; query-source port 53; query-source-v6 port 53; allow-query { any; }; //允许使用本DNS服务的网段};zone "benet.com" IN { //正向”benet.com“区域 type master; //类型为主区域 file "benet.com.zone"; //区域数据文件为benet.com.zone};zone "accp.com" IN { type master; file "accp.com.zone";};
zone "16.16.173.in-addr.arpa" IN{ //反向查询区域
type master;
file "172.16.16.arpa";
};
[root@dnssvr ~]# named-checkconfig -z /var/named/chroot/etc/named.conf
[root@dnssvr ~]# cp -p /var/named/chroot/var/named/localhost.zone /var/named/chroot/var/named/benet.com.zone //复制区域模版
[root@dnssvr ~]#cp -p /var/named/chroot/var/named/localhost.zone /var/named/chroot/var/named/accp.com.zone
[root@dnssvr ~]# cp /var/named/chroot/var/named/named.local /var/named/chroot/var/named/172.16.16.arpa
配置区域数据配置文件
[root@dnssvr ~]# cat /var/named/chroot/var/named/benet.com.zone $TTL86400@ IN SOAbenet.com. root.benet.com. (42 ; serial (d. adams)3H ; refresh15M ; retry1W ; expiry1D ) ; minimum
@ IN NS dnssvr.benet.com.dnssvr IN A 192.168.100.3
@ IN MX 10 mail.benet.comwww IN A 192.168.100.2
mail IN A 192.168.100.2
[root@dnssvr ~]# vim /var/named/chroot/var/named/accp.com.zone
@ IN SOA accp.com. root.accp.com (42 ; serial (d. adams)3H ; refresh15M ; retry1W ; expiry1D ) ; minimum
@ IN NS dnssvr.benet.com.
www IN A 192.168.100.2
[root@dnssvr ~]# vim /var/named/chroot/var/named/172.16.16.arpa$TTL86400@ IN SOA benet.com. root.benet.com. ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS dnssvr.benet.com.1 IN PTR www.benet.com
检查:
[root@dnssvr ~]# cd /var/named/chroot/var/named/
[root@dnssvr named]# named-checkzone benet.com benet.com.zone zone benet.com/IN: loaded serial 42OK[root@dnssvr named]# named-checkzone accp.com accp.com.zone zone accp.com/IN: loaded serial 42OK[root@dnssvr named]# named-checkzone benet.com benet.com.zone
zone benet.com/IN: loaded serial 42
OK
[root@dnssvr named]# named-checkzone 16.16.173.in-addr.arpa 172.16.16.arpa
zone benet.com/IN: loaded serial 42
OK
[root@dnssvr named]# ervice named restart
停止 named: [确定]
启动 named: [确定]