使用BIND来搭建简单的主辅DNS服务器
2014-09-25 15:27
197 查看
http://yuanbin.blog.51cto.com/363003/108627
文中有不对或者有不清楚的地方,请大家告诉我,谢谢!
使用BIND来搭建简单的主辅DNS服务器
一.安装BIND
在系统中使用rpm –qa |grep bind查看有没有安装BIND包。如果没有安装,则将系统盘挂载,使用rpm –ivh *bind* 安装。
![](http://img1.51cto.com/attachment/200810/28/363003_1225192441zI5w.gif)
二.启动BIND
service named start
chkconfig --level 35 named on
三.试验拓扑
试验拓扑如下图,使用bob.com域:
![](http://img1.51cto.com/attachment/200810/28/363003_1225192447g84Q.jpg)
四.配置Master DNS
1. 编辑DNS的主配置文件named.conf
vi /etc/named.conf
options {
directory "/var/named";
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "bob.com" IN {
type master;
file "bob.com.dns";
allow-update { none; };
allow-transfer { 192.168.120.241; };
};
zone "120.168.192.in-addr.arpa" IN {
type master;
file "bob.com.rev";
allow-update { none; };
allow-transfer { 192.168.120.241; };
};
include "/etc/rndc.key";
2. 编辑区域数据文件
vi /var/named/chroot/var/named/bob.com.dns
$TTL 86400
$ORIGIN bob.com.
@ IN SOA bob.com. root.bob.com. (
2 ; serial
120 ; refresh
14400 ; retry
3600000 ; expiry
86400 ) ; minimum
IN NS bob.com.
master IN A 192.168.120.240
slave IN A 192.168.120.241
www IN A 192.168.120.250
vi /var/named/chroot/var/named/bob.com.rev
$TTL 86400
@ IN SOA bob.com. root.bob.com. (
2 ; Serial
120 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS bob.com.
240 IN PTR master.bob.com.
241 IN PTR slave.bob.com.
250 IN PTR www.bob.com.
chown named.named /var/named/chroot/var/named/bob.com.*
3. 测试
① 在Master DNS上使用host命令查看信息:
[root@master /]# host
www.bob.com
www.bob.com has address 192.168.120.250
[root@master /]# host master.bob.com
master.bob.com has address 192.168.120.240
[root@master /]# host slave.bob.com
slave.bob.com has address 192.168.120.241
② 在Master DNS上使用nslookup命令查看信息:
[root@master /]# nslookup
> www.bob.com
Server: 192.168.120.240
Address: 192.168.120.240#53
Name: www.bob.com
Address: 192.168.120.250
> master.bob.com
Server: 192.168.120.240
Address: 192.168.120.240#53
Name: master.bob.com
Address: 192.168.120.240
> 192.168.120.250
Server: 192.168.120.240
Address: 192.168.120.240#53
250.120.168.192.in-addr.arpa name=www.bob.com.
③ 在用户pc上将DNS指向192.168.120.240,然后访问www.bob.com
![](http://img1.51cto.com/attachment/200810/28/363003_12251924504FAm.jpg)
4. 查看日志
[root@master /]#service named start
[root@master /]#cat /var/log/messages |grep named
Sep 8 18:24:35 master named[15322]:
starting BIND 9.2.4 -u named -t /var/named/chroot
Sep 8 18:24:35 master named[15322]: using 1 CPU
Sep 8 18:24:35 master named[15322]: loading configuration from '/etc/named.conf'
Sep 8 18:24:35 master named[15322]: listening on IPv4 interface lo, 127.0.0.1#53
Sep 8 18:24:35 master named[15322]: listening on IPv4 interface eth0, 192.168.120.240#53
Sep 8 18:24:35 master named[15322]: command channel listening on 127.0.0.1#953
Sep 8 18:24:35 master named[15322]: command channel listening on ::1#953
Sep 8 18:24:35 master named[15322]:
zone 0.0.127.in-addr.arpa/IN: loaded serial 1997022700
Sep 8 18:24:35 master named[15322]: zone 120.168.192.in-addr.arpa/IN: loaded serial 2
Sep 8 18:24:35 master named[15322]:
zone bob.com/IN: loaded serial 2
Sep 8 18:24:35 master named[15322]: zone localhost/IN: loaded serial 42
Sep 8 18:24:35 master named[15322]: named startup succeeded
Sep 8 18:24:35 master named[15322]:
running
5. 注意事项
A.修改区域数据文件在每次存盘时要注意增加Serial值,主要用来让辅助服务器同步主服务器的区域数据文件。
B.使用绝对域名时千万别忘了后面要带"."。
C.主配置文件named.conf的";"不能少。
五.配置Slave DNS
1. 编辑DNS的主配置文件named.conf
vi /etc/named.conf
options {
directory "/var/named";
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "bob.com" IN {
type slave;
file "slaves/bob.com.dns";
masters { 192.168.120.240; };
};
zone "120.168.192.in-addr.arpa" IN {
type slave;
file "slaves/bob.com.rev";
masters { 192.168.120.240; };
};
include "/etc/rndc.key"
2. 修改从主DNS复制过来的区域文件存放目录的权限
cd /var/named/chroot/var/named/slaves
chmod 775 /var/named/chroot/var/named/slaves
chown named.named /var/named/chroot/var/named/slaves
3. 测试
① 在Slave DNS上查看区域数据文件有没有从主DNS复制过来
[root@slave /]#ll /var/named/chroot/var/named/slaves
-rw------- 1 named named 406 Jun 13 23:50 bob.com.dns
-rw------- 1 named named 410 Jun 13 19:10 bob.com.rev
② 在Slave DNS上使用host命令查看信息
[root@slave /]# host
www.bob.com
www.bob.com has address 192.168.120.250
[root@slave /]# host master.bob.com
master.bob.com has address 192.168.120.240
[root@slave /]# host slave.bob.com
slave.bob.com has address 192.168.120.241
③ 在slave DNS上使用nslookup命令查看信息
[root@slave /]# nslookup
> www.bob.com
Server: 192.168.120.241
Address: 192.168.120.241#53
Name: www.bob.com
Address: 192.168.120.250
> master.bob.com
Server: 192.168.120.241
Address: 192.168.120.241#53
Name: master.bob.com
Address: 192.168.120.240
> 192.168.120.250
Server: 192.168.120.241
Address: 192.168.120.241#53
250.120.168.192.in-addr.arpa name=www.bob.com.
④ 在用户pc上将DNS指向192.168.120.241,然后访问www.bob.com
![](http://img1.51cto.com/attachment/200810/28/363003_1225192453agJO.jpg)
4. 查看日志
[root@slaves /]#services named start
[root@slaves /]# cat /var/log/messages |grep named
Jun 14 00:04:48 slave named[10083]: starting BIND 9.2.4 -u named -t /var/named/chroot
Jun 14 00:04:48 slave named[10083]: using 1 CPU
Jun 14 00:04:48 slave named[10083]:
loading configuration from '/etc/named.conf'
Jun 14 00:04:48 slave named[10083]: listening on IPv4 interface lo, 127.0.0.1#53
Jun 14 00:04:48 slave named[10083]: listening on IPv4 interface eth0, 192.168.120.241#53
Jun 14 00:04:48 slave named[10083]: command channel listening on 127.0.0.1#953
Jun 14 00:04:48 slave named[10083]: command channel listening on ::1#953
Jun 14 00:04:49 slave named[10083]: zone 0.0.127.in-addr.arpa/IN: loaded serial 1997022700
Jun 14 00:04:49 slave named[10083]: zone localhost/IN: loaded serial 42
Jun 14 00:04:49 slave named[10083]: named startup succeeded
Jun 14 00:04:49 slave named[10083]: running
Jun 14 00:04:49 slave named[10083]: zone 120.168.192.in-addr.arpa/IN: transferred serial 2
Jun 14 00:04:49 slave named[10083]: transfer of '120.168.192.in-addr.arpa/IN' from 192.168.120.240#53: end of transfer
Jun 14 00:04:49 slave named[10083]: zone bob.com/IN: transferred serial 2
Jun 14 00:04:49 slave named[10083]: transfer of 'bob.com/IN' from 192.168.120.240#53: end of transfer
5. 注意事项
A.从主DNS复制过来的区域文件存放目录的权限。
B.主配置文件named.conf的";"不能少。
文中有不对或者有不清楚的地方,请大家告诉我,谢谢!
使用BIND来搭建简单的主辅DNS服务器
一.安装BIND
在系统中使用rpm –qa |grep bind查看有没有安装BIND包。如果没有安装,则将系统盘挂载,使用rpm –ivh *bind* 安装。
![](http://img1.51cto.com/attachment/200810/28/363003_1225192441zI5w.gif)
二.启动BIND
service named start
chkconfig --level 35 named on
三.试验拓扑
试验拓扑如下图,使用bob.com域:
![](http://img1.51cto.com/attachment/200810/28/363003_1225192447g84Q.jpg)
四.配置Master DNS
1. 编辑DNS的主配置文件named.conf
vi /etc/named.conf
options {
directory "/var/named";
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "bob.com" IN {
type master;
file "bob.com.dns";
allow-update { none; };
allow-transfer { 192.168.120.241; };
};
zone "120.168.192.in-addr.arpa" IN {
type master;
file "bob.com.rev";
allow-update { none; };
allow-transfer { 192.168.120.241; };
};
include "/etc/rndc.key";
2. 编辑区域数据文件
vi /var/named/chroot/var/named/bob.com.dns
$TTL 86400
$ORIGIN bob.com.
@ IN SOA bob.com. root.bob.com. (
2 ; serial
120 ; refresh
14400 ; retry
3600000 ; expiry
86400 ) ; minimum
IN NS bob.com.
master IN A 192.168.120.240
slave IN A 192.168.120.241
www IN A 192.168.120.250
vi /var/named/chroot/var/named/bob.com.rev
$TTL 86400
@ IN SOA bob.com. root.bob.com. (
2 ; Serial
120 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS bob.com.
240 IN PTR master.bob.com.
241 IN PTR slave.bob.com.
250 IN PTR www.bob.com.
chown named.named /var/named/chroot/var/named/bob.com.*
3. 测试
① 在Master DNS上使用host命令查看信息:
[root@master /]# host
www.bob.com
www.bob.com has address 192.168.120.250
[root@master /]# host master.bob.com
master.bob.com has address 192.168.120.240
[root@master /]# host slave.bob.com
slave.bob.com has address 192.168.120.241
② 在Master DNS上使用nslookup命令查看信息:
[root@master /]# nslookup
> www.bob.com
Server: 192.168.120.240
Address: 192.168.120.240#53
Name: www.bob.com
Address: 192.168.120.250
> master.bob.com
Server: 192.168.120.240
Address: 192.168.120.240#53
Name: master.bob.com
Address: 192.168.120.240
> 192.168.120.250
Server: 192.168.120.240
Address: 192.168.120.240#53
250.120.168.192.in-addr.arpa name=www.bob.com.
③ 在用户pc上将DNS指向192.168.120.240,然后访问www.bob.com
![](http://img1.51cto.com/attachment/200810/28/363003_12251924504FAm.jpg)
4. 查看日志
[root@master /]#service named start
[root@master /]#cat /var/log/messages |grep named
Sep 8 18:24:35 master named[15322]:
starting BIND 9.2.4 -u named -t /var/named/chroot
Sep 8 18:24:35 master named[15322]: using 1 CPU
Sep 8 18:24:35 master named[15322]: loading configuration from '/etc/named.conf'
Sep 8 18:24:35 master named[15322]: listening on IPv4 interface lo, 127.0.0.1#53
Sep 8 18:24:35 master named[15322]: listening on IPv4 interface eth0, 192.168.120.240#53
Sep 8 18:24:35 master named[15322]: command channel listening on 127.0.0.1#953
Sep 8 18:24:35 master named[15322]: command channel listening on ::1#953
Sep 8 18:24:35 master named[15322]:
zone 0.0.127.in-addr.arpa/IN: loaded serial 1997022700
Sep 8 18:24:35 master named[15322]: zone 120.168.192.in-addr.arpa/IN: loaded serial 2
Sep 8 18:24:35 master named[15322]:
zone bob.com/IN: loaded serial 2
Sep 8 18:24:35 master named[15322]: zone localhost/IN: loaded serial 42
Sep 8 18:24:35 master named[15322]: named startup succeeded
Sep 8 18:24:35 master named[15322]:
running
5. 注意事项
A.修改区域数据文件在每次存盘时要注意增加Serial值,主要用来让辅助服务器同步主服务器的区域数据文件。
B.使用绝对域名时千万别忘了后面要带"."。
C.主配置文件named.conf的";"不能少。
五.配置Slave DNS
1. 编辑DNS的主配置文件named.conf
vi /etc/named.conf
options {
directory "/var/named";
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "bob.com" IN {
type slave;
file "slaves/bob.com.dns";
masters { 192.168.120.240; };
};
zone "120.168.192.in-addr.arpa" IN {
type slave;
file "slaves/bob.com.rev";
masters { 192.168.120.240; };
};
include "/etc/rndc.key"
2. 修改从主DNS复制过来的区域文件存放目录的权限
cd /var/named/chroot/var/named/slaves
chmod 775 /var/named/chroot/var/named/slaves
chown named.named /var/named/chroot/var/named/slaves
3. 测试
① 在Slave DNS上查看区域数据文件有没有从主DNS复制过来
[root@slave /]#ll /var/named/chroot/var/named/slaves
-rw------- 1 named named 406 Jun 13 23:50 bob.com.dns
-rw------- 1 named named 410 Jun 13 19:10 bob.com.rev
② 在Slave DNS上使用host命令查看信息
[root@slave /]# host
www.bob.com
www.bob.com has address 192.168.120.250
[root@slave /]# host master.bob.com
master.bob.com has address 192.168.120.240
[root@slave /]# host slave.bob.com
slave.bob.com has address 192.168.120.241
③ 在slave DNS上使用nslookup命令查看信息
[root@slave /]# nslookup
> www.bob.com
Server: 192.168.120.241
Address: 192.168.120.241#53
Name: www.bob.com
Address: 192.168.120.250
> master.bob.com
Server: 192.168.120.241
Address: 192.168.120.241#53
Name: master.bob.com
Address: 192.168.120.240
> 192.168.120.250
Server: 192.168.120.241
Address: 192.168.120.241#53
250.120.168.192.in-addr.arpa name=www.bob.com.
④ 在用户pc上将DNS指向192.168.120.241,然后访问www.bob.com
![](http://img1.51cto.com/attachment/200810/28/363003_1225192453agJO.jpg)
4. 查看日志
[root@slaves /]#services named start
[root@slaves /]# cat /var/log/messages |grep named
Jun 14 00:04:48 slave named[10083]: starting BIND 9.2.4 -u named -t /var/named/chroot
Jun 14 00:04:48 slave named[10083]: using 1 CPU
Jun 14 00:04:48 slave named[10083]:
loading configuration from '/etc/named.conf'
Jun 14 00:04:48 slave named[10083]: listening on IPv4 interface lo, 127.0.0.1#53
Jun 14 00:04:48 slave named[10083]: listening on IPv4 interface eth0, 192.168.120.241#53
Jun 14 00:04:48 slave named[10083]: command channel listening on 127.0.0.1#953
Jun 14 00:04:48 slave named[10083]: command channel listening on ::1#953
Jun 14 00:04:49 slave named[10083]: zone 0.0.127.in-addr.arpa/IN: loaded serial 1997022700
Jun 14 00:04:49 slave named[10083]: zone localhost/IN: loaded serial 42
Jun 14 00:04:49 slave named[10083]: named startup succeeded
Jun 14 00:04:49 slave named[10083]: running
Jun 14 00:04:49 slave named[10083]: zone 120.168.192.in-addr.arpa/IN: transferred serial 2
Jun 14 00:04:49 slave named[10083]: transfer of '120.168.192.in-addr.arpa/IN' from 192.168.120.240#53: end of transfer
Jun 14 00:04:49 slave named[10083]: zone bob.com/IN: transferred serial 2
Jun 14 00:04:49 slave named[10083]: transfer of 'bob.com/IN' from 192.168.120.240#53: end of transfer
5. 注意事项
A.从主DNS复制过来的区域文件存放目录的权限。
B.主配置文件named.conf的";"不能少。
相关文章推荐
- 使用BIND来搭建简单的主辅DNS服务器 推荐
- DNS浅析-Bind软件的使用及搭建一个简单的DNS缓存服务器
- Linux下使用Bind搭建域名服务器
- 使用bind搭建主辅DNS服务器
- windows下使用gvim搭建简单的IDE编译环境(支持C/C++/Python等)
- Redis 集群搭建和简单使用教程
- 使用zendframework 1.8搭建一个简单的网站构架
- 使用bind搭建主辅DNS服务器(已测试)
- 【转帖】windows下使用gvim搭建简单的IDE编译环境(支持C/C++/Python等)
- TortoiseSVN搭建本地版本库及简单操作使用
- 使用intellij idea 搭建springmvc例子【简单景点登录】
- 使用mingw在windows下搭建c/c++ IDE简单开发环境
- LinuxC/C++编程基础(21) 使用boost::asio搭建服务器简单实例(续)
- (转载)使用OpenDIR搭建简单的图像检索系统
- std::bind,std::cref的简单使用
- Window平台使用VS2010简单快速搭建QT开发环境
- Linux中的bind服务器的简单搭建
- 【Azure Services Platform Step by Step-第10篇】使用Blob Storage搭建简单网络硬盘
- 使用Mysql搭建简单的可持续的Cache系统
- yum的安装的使用搭建简单的apache服务器