软件包bind,提供域名服务的主要程序及相关文件。
软件包bind-utils,提供对DNS服务器的测试工具程序,如nslookup。
注释:BIND是最受欢迎的能够提供域名服务的DNS服务程序。
[root@localhost ~]# mount /dev/cdrom /mnt----挂光盘
[root@localhost ~]# rpm -ivh /mnt/Packages/bind-9.8.2-2-0.
17.rcl.e16.i686.rpm-----用rpm装bind软件包
[root@kimi ~]# rpm -ivh /mnt/Packages/bind-utils-9.8.2-0.17.
rc1.el6.i686.rpm-----用rpm装bind-utils软件包
[root@localhost ~]# rpm -qa | grep "bind"
注释:主配置文件用于设置named服务的全局配置,注册区域和访问控制等各种运动参数。
[root@localhost ~]# vi /etc/named.conf
options {
listen-on port 53 { 192.168.80.10; }; //设置本地IP地址为监听地址
directory "/var/named";
allow-query { any; }; //允许任何人访问DNS服务器
};
注释:区域数据文件用于存放某个DNS区域的地址解析记录(正向和反向记录)。
[root@localhost ~]# vi /etc/named.rfc1912.zones
zone "benet.com" IN {
type master; //设置类型为正主区域
file "benet.com.zone"; //区域数据文件为benet.com.zone
allow-transfer { 192.168.80.9; }; //允许从服务器下载正向区域数据文件
also-notify { 192.168.80.9; };
};
zone "80.168.192.in-addr.arpa" IN {
type master; //设置类型为反主区域
file "benet.com.local."; //区域数据文件为benet.com.local.
allow-transfer { 192.168.80.9; }; //允许从服务器下载正向区域数据文件
also-notify { 192.168.80.9; };
};
[root@localhost ~]# ls -l /var/named
[root@localhost ~]# cd /var/named
[root@localhost named]# vi benet.com.zone //编辑正向查找配置文件
$TTL 1D
@ IN SOA @ admin.benet.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS www.benet.com.
www A 192.168.80.10
FTP A 192.168.80.9
alias CNAME www
[email=%5Broot@localhostnamed%5D#echo][root@localhostnamed]# echo "nameserver192.168.80.10" >[/email]
/etc/resolv.conf //为主服务器指定DNS
[root@localhost named]# cat /etc/resolv.conf
nameserver 192.168.80.10
[root@localhost named]# service iptables stop
Iptables:清除防火墙规则: [确定]
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:正在卸载模块: [确定]
[root@localhost named]# setenforce 0
[root@localhost named]# service named start
启动 named: [确定]
[root@localhost named]# ping www.benet.com
[root@localhost named]# nslookup www.benet.com
Server: 192.168.80.10
Address: 192.168.80.10#53
Name: www.benet.com
Address: 192.168.80.10
[root@localhost ~]# cd /var/named
[root@localhost named]# cp -p named.loopback benet.com.local.
[root@localhost named]# ls -l benet.com.local
-rw-r--r--. 1 root named 0 3月 8 00:28 benet.com.local
$TTL 1D
@ IN SOA 80.168.192,in-addr.arpa admin.benet.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
10 PTR www.benet.com.
9 PTR ftp.benet.com.
~
[root@localhost named]# service named restart
停止 named: [确定]
启动 named: [确定]
[root@localhost named]# ping 192.168.80.10
[root@localhost named]# nslookup 192.168.80.10
Server: 192.168.80.10
Address: 192.168.80.10#53
10.80.168.192.in-addr.arpa name = www.benet.com.
[root@localhost ~]# mount /dev/cdrom /mnt
[root@localhost ~]# yum install openssh-clients
[root@localhost ~]# ssh 192.168.80.9
[email protected]'s password:
Last login: Sat Mar 8 04:24:15 2014 from 192.168.80.5
[root@kimi ~]#vi /etc/named.conf
zone "benet.com" IN {
type slave; //设置类型为从区域
masters { 192.168.80.10; }; //设置主服务器的IP地址
allow-notify { 192.168.80.10; };
file "slave/benet.com.zone"; //下载区域文件保存的路径
};
[root@kimi ~]#echo "nameserver 192.168.80.9" >/etc/resolv.
conf
[root@kimi ~]# service iptables stop
iptables:清除防火墙规则: [确定]
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:正在卸载模块: [确定]
[root@kimi ~]# setenforce 0
[root@kimi ~]# service named start
启动 named: [确定]
当正向www.benet.com、ftp.benet.com存在时
主:
验证www.benet.com的正向查找
验证ftp.benet.com的正向查找
从:
验证www.benet.com的正向查找
验证ftp.benet.com的正向查找
删除正向ftp.benet.com对应192.168.80.9后
利用service named restart重启主、从服务器
主:
验证ftp.benet.com正向查找
从:
验证ftp.benet.com正向查找