Bind 搭建 DNS(应用:域名方式配置分布式集群,扩展方便)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wangxilong1991/article/details/70258702
[root@vm20702 ~]# yum install -y bind bind-chroot bind-utils
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Package 32:bind-utils-9.8.2-0.17.rc1.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package bind.x86_64 32:9.8.2-0.17.rc1.el6 will be installed
---> Package bind-chroot.x86_64 32:9.8.2-0.17.rc1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================================================================================================
 Package                                          Arch                                        Version                                                    Repository                                 Size
=========================================================================================================================================================================================================
Installing:
 bind                                             x86_64                                      32:9.8.2-0.17.rc1.el6                                      iso6                                      4.0 M
 bind-chroot                                      x86_64                                      32:9.8.2-0.17.rc1.el6                                      iso6                                       70 k

Transaction Summary
=========================================================================================================================================================================================================
Install       2 Package(s)

Total download size: 4.0 M
Installed size: 7.2 M
Downloading Packages:
(1/2): bind-chroot-9.8.2-0.17.rc1.el6.x86_64.rpm                                                                                                                                  |  70 kB     00:00     
(2/2): bind-9.8.2-0.17.rc1.el6.x86_64.rpm                                                                                                                                         | 4.0 MB     00:00     
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                     29 MB/s | 4.0 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 32:bind-9.8.2-0.17.rc1.el6.x86_64                                                                                                                                                     1/2 
  Installing : 32:bind-chroot-9.8.2-0.17.rc1.el6.x86_64                                                                                                                                              2/2 
  Verifying  : 32:bind-chroot-9.8.2-0.17.rc1.el6.x86_64                                                                                                                                              1/2 
  Verifying  : 32:bind-9.8.2-0.17.rc1.el6.x86_64                                                                                                                                                     2/2 

Installed:
  bind.x86_64 32:9.8.2-0.17.rc1.el6                                                               bind-chroot.x86_64 32:9.8.2-0.17.rc1.el6                                                              

Complete!
[root@vm20702 ~]# rpm -qa |grep bind
ypbind-1.20.4-30.el6.x86_64
samba-winbind-clients-3.6.9-151.el6.x86_64
bind-chroot-9.8.2-0.17.rc1.el6.x86_64
rpcbind-0.2.0-11.el6.x86_64
bind-libs-9.8.2-0.17.rc1.el6.x86_64
samba-winbind-3.6.9-151.el6.x86_64
bind-9.8.2-0.17.rc1.el6.x86_64
bind-utils-9.8.2-0.17.rc1.el6.x86_64
[root@vm20702 ~]# vim /etc/na
named/               named.conf           named.iscdlv.key     named.rfc1912.zones  named.root.key       nanorc               
[root@vm20702 ~]# vim /etc/named.conf 
[root@vm20702 ~]# 

这里写图片描述

[root@vm20702 named]# vim /etc/named.rfc1912.zones 

这里写图片描述

[root@vm20702 var]# cd /var/named/
[root@vm20702 named]# cp named.localhost wxl.come.zone
[root@vm20702 named]# cp named.localhost 2.16.172.zone
[root@vm20702 named]# vim wxl.com.zone 
$TTL 1D
@       IN SOA  vm20702.wxl.com root (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
@       IN      NS      vm20702
vm20702 IN      A       172.16.2.79
vm20703 IN      A       172.16.2.84
vm20602 IN      A       172.16.2.78
X207    IN      A       172.16.2.207
X203    IN      A       172.16.2.203
X206    IN      A       172.16.2.206


[root@vm20702 named]# vim 2.16.172.zone
$TTL 1D
@       IN SOA  vm20702.wxl.com root (
                                        12      ; serial
                                        28800   ; refresh
                                        14400   ; retry
                                        3600000 ; expire
                                        86400 ) ; minimum
@       IN      NS      vm20702.wxl.com.
78      IN      PTR     vm20602.wxl.com.
79      IN      PTR     vm20702.wxl.com.
84      IN      PTR     vm20703.wxl.com.
206     IN      PTR     X206.wxl.com.
207     IN      PTR     X207.wxl.com.
203     IN      PTR     X203.wxl.com.
检查之前先看下 配置文件有没有读取权限 ll /var/named 

(如果没有读取权限, chmod +r /var/named/*  即可)

检查bind文件配置过程中容易出错

以下命令用以检查bind配置文件及zone文件语法

named-checkzone wxl.com /var/named/wxl.com.zone

[root@vm20702 named]# named-checkconf /etc/named.conf
[root@vm20702 named]# named-checkzone wxl.com /var/named/wxl.com.zone
zone wxl.com/IN: loaded serial 0
OK
[root@vm20702 named]# 

[root@vm20702 named]# service named start

可能出现问题:

启动或重启DNS服务时,卡在Generating /etc/rndc.key:上很长时间
解决方法:
执行以下命令:
rndc-confgen -r /dev/urandom -a
然后再重启DNS服务:
service named start
服务正常

测试

[root@vm20702 named]# nslookup
> vm20703.wxl.com
Server:     172.16.2.79
Address:    172.16.2.79#53

Name:   vm20703.wxl.com
Address: 172.16.2.84
> 172.16.2.78
Server:     172.16.2.79
Address:    172.16.2.79#53

78.2.16.172.in-addr.arpa    name = vm20602.wxl.com.
>

客户端测试
1 添加DNS域名服务器ip(这里注意修改/etc/resolv.conf是没用的,重启电脑就失效了)

[root@vm20602 mdss]# vim /etc/resolv.conf 
nameserver 172.16.2.79
[root@vm20602 mdss]# nslookup
> vm20702.wxl.com
Server:     172.16.2.79
Address:    172.16.2.79#53

Name:   vm20702.wxl.com
Address: 172.16.2.79
> 172.16.2.206
Server:     172.16.2.79
Address:    172.16.2.79#53

206.2.16.172.in-addr.arpa   name = X206.wxl.com.
> 
[root@vm20602 mdss]# ping X207.wxl.com
PING X207.wxl.com (172.16.2.207) 56(84) bytes of data.
64 bytes from y207 (172.16.2.207): icmp_seq=1 ttl=64 time=0.570 ms


64 bytes from y207 (172.16.2.207): icmp_seq=2 ttl=64 time=0.622 ms
64 bytes from y207 (172.16.2.207): icmp_seq=3 ttl=64 time=0.631 ms
64 bytes from y207 (172.16.2.207): icmp_seq=4 ttl=64 time=0.648 ms
64 bytes from y207 (172.16.2.207): icmp_seq=5 ttl=64 time=0.534 ms
64 bytes from y207 (172.16.2.207): icmp_seq=6 ttl=64 time=0.519 ms
64 bytes from y207 (172.16.2.207): icmp_seq=7 ttl=64 time=0.649 ms
64 bytes from y207 (172.16.2.207): icmp_seq=8 ttl=64 time=0.532 ms
64 bytes from y207 (172.16.2.207): icmp_seq=9 ttl=64 time=0.661 ms
^C
--- X207.wxl.com ping statistics ---
9 packets transmitted, 9 received, 0% packet loss, time 8389ms
rtt min/avg/max/mdev = 0.519/0.596/0.661/0.056 ms
[root@vm20602 mdss]# 

2 找到网卡,添加DNS服务器
这里需要找到/etc/sysconfig/network-scripts/ifcfg-eth1
主要是加入DNS1=172.16.2.79

[root@vm20602 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1 
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=172.16.2.78
NETMASK=255.255.0.0
HWADDR=52:54:00:9D:B2:26
#eth2      Link encap:Ethernet  HWaddr 52:54:00:9D:B2:26
#eth3      Link encap:Ethernet  HWaddr 52:54:00:4C:3D:AE
DNS1=172.16.2.79
[root@vm20703 ~]# service network restart
正在关闭接口 eth0:                                        [确定]
正在关闭接口 eth1:                                        [确定]
关闭环回接口:                                             [确定]
弹出环回接口:                                             [确定]
弹出界面 eth0:                                            [确定]
弹出界面 eth1:                                            [确定]

[root@vm20602 ~]# nslookup vm20702.wxl.com
Server:     172.16.2.79
Address:    172.16.2.79#53

Name:   vm20702.wxl.com
Address: 172.16.2.79

详细参考:
http://www.cnblogs.com/zhumao/archive/2005/07/20/196825.html

http://www.cnblogs.com/demonzk/p/6494968.html
http://zzk.cnblogs.com/s/blogpost?Keywords=DNS+bind
正式生产环境下hadoop集群的DNS+NFS+ssh免密码登陆配置

展开阅读全文

没有更多推荐了,返回首页