准备:
加载光驱:mount /dev/cdrom /mnt/cdrom/
如需更换光盘请先卸载光驱:umount /mnt/cdrom 或 eject
解压bind包:tar xzf bind-9.2.3.tar.gz -C /usr/local/src/
编译,配置和安装:cd /usr/local/src/bind-9.2.3
./configure--prefix=/usr/local/bind && make && make install
将程序安装盘的RedHat 9第二张光盘(RedHat AS 4 第一张光盘)放到光驱里,找到caching-nameserver-7.3-3.noarch.rpm
执行rpm ivh caching-nameserver-7.3-3.noarch.rpm --nodeps (没有依赖关系)
生成rndc.key文件:/usr/local/bind/sbin/rndc-confgen > /etc/rndc.conf
mv /etc/rndc.conf /etc/rndc.key
编辑/etc/rndc.key
删除前四行以外的内容!!
配置文件:
主配置文件:/etc/named.conf
配置区域文件
切换到bind安装目录/usr/local/bind/sbin/目录下
检查主配置文件语法命令:
./named-checkconf /etc/named.conf
检查区域文件:
./named-checkzone guoyuan.com /var/named/0.168.192
./named-checdzone guoyuan.com /var/named/guoyuan.com
看有没有错误,若没有错误则运行bind服务
运行:/usr/local/bind/sbin/named -c /etc/named.conf
若输入不输入 -c参数则出现named的所有参数。如
[root@host sbin]# ./named /etc/named.conf
usage: named [-c conffile] [-d debuglevel] [-f|-g] [-n number_of_cpus]
[-p port] [-s] [-t chrootdir] [-u username]
查看日志
tail -n 20 /var/log/messages
排除故障,
运行/usr/local/bind/sbin/named -c /etc/named.conf
查看进程:ps -aux|grep named
查看端口:netstat -an |grep 53
注:
1、区域文件要求设置NS记录(必须),mx记录,A 记录 CNAME记录
配置文件如:
$TTL 86400
@ IN SOA test root.guoyuan.com. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
IN NS test.guoyuan.com.
test.guoyuan.com. IN A 192.168.0.26
ftp IN A 192.168.0.24
webserver IN A 192.168.0.3
IN A 192.168.0.26
IN A 192.168.4.2
www IN CNAME webserver
mail IN A 192.168.0.26
@ IN MX 5 mail
test1.guoyuan.com. IN A 192.168.2.4
若要求批量加入域名如:station100.guoyuan.com ---station200.guoyuan.com在区域文件里加入下面语句:
$generate 100-200 station$.guoyuan.com. A 192.168.0.$
2、若开机是自动加载named:
用vi在/etc/rc.d/rc.local 文件里加入 /usr/local/bind/sbin/named -c /etc/named.conf
或者
输入echo "/usr/local/bind/sbin/named -c /etc/named.conf" >>/etc/rc.d/rc.local
两种形式均是向阳花/etc/rc.d/rc.local中写入"/usr/local/bind/sbin/named -c /etc/named.conf"这条语句!