Ip地址规划:
Master dns 192.168.0.30
Slave dns :192.168.0.50
http: 192.168.0.30
client:192.168.0.10
一.主DNS服务器
先安装bind
Bind-9.3
Bind-utils
Bind-chroot-9
编辑dhs的主配置文件
vim /var/named/chroot/etc/named.conf
options {
directory "/var/named";
};
zone "vfast.com" {
type master;
file "vfast.com.zone";
allow-transfer {192.168.0.50;}; ##允许传输
};
zone "0.168.192.in-addr.arpa" {
type master;
file "vfast.com.192.168.0";
allow-transfer {192.168.0.50;}; ##允许传输
};
编辑正向解析文件和反向解析文件
拷贝模版
cp /usr/share/doc/bind-9.3.6/sample/var/named/localhost.zone /var/named/chroot/var/named/ vfast.com.zone
然后编译正向文件vim /var/named/chroot/var/named/vfast.com.zone
添加
@ IN NS master.vfast.com.
master IN A 192.168.18.30
www IN CHAME master.vfast.com
#编辑反向区域文件
cp vfast.com.zone var/named/chroot/var/named/vfast.com.192.168.0
vim vfast.com.192.168.18
添加
@ IN NS master.vfast.com.
30 IN PTR www.vfast.com.
然后更改主机的dns指向 vim /etc/resolv.conf
nameserver 192.168.0.30
修改权限 cd /var/named/chroot/var 下
chmod -R g+w named/
然后重启服务 /etc/init.d/named restart
再在此服务器上安装HTTP服务
yum install -y httpd
/etc/init.d/httpd restart
vim /var/www/html/index.html
hello vfast
/etc/init.d/httpd restart
二.搭建辅助DNS服务器
安装bind
yum install -y bind*
配置辅DNS的主配置文件 vim /var/named/chroot/etc/named.conf
options {
directory "/var/named";
};
zone "vfast.com" {
type slave;
file "vfast.com.zone";
masters {192.168.0.30;};
};
zone "0.168.192.in-addr.arpa" {
type slave;
file "wangjian.com.192.168.0";
masters {192.168.0.30;};
};/var/named/chroot/var
修改辅助DNS服务器的DNS指向自己 vim /etc/resolv.conf
nameserver 192.168.0.50
修改权限 cd /var/named/chroot/var 下
chmod -R g+w named/
然后重启DNS服务 /etc/init.d/named restart
没有问题的话,辅助DNS的应该从主DNS服务器上copy过来了区域文件
三 搭建DNS完全转发服务器
安装BIND yum install bind*
vim /var/named/chroot/etc/named.conf
options {
directory "/var/named";
recursion yes; ###允许递归查询
forwarders {192.168.0.30;192.168.0.50}; 转发给谁
forward only ;
};
把DNS指向自己 vim /etc/resolv.conf
nameserver 192.168.0.70
重启dns服务器
四.客户端测试
设置客户端DNS为转发服务器的192.168.0.70
在客户端上测试www.vfast.com