centos配置dns服务器

前端之家收集整理的这篇文章主要介绍了centos配置dns服务器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、配置yum源

http://blog.csdn.net/kadwf123/article/details/78231694

2、修改服务器的主机名:

[root@MYDNS ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=MYDNS
改成MYDNS

3、使用yum源安装dns服务包

[root@MYDNS etc]# yum -y install bind-libs bind bind-utils
Loaded plugins: fastestmirror,security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package bind.x86_64 32:9.8.2-0.62.rc1.el6_9.4 will be installed
---> Package bind-libs.x86_64 32:9.8.2-0.17.rc1.el6 will be updated
---> Package bind-libs.x86_64 32:9.8.2-0.62.rc1.el6_9.4 will be an update
--> Processing Dependency: libcrypto.so.10(libcrypto.so.10)(64bit) for package: 32:bind-libs-9.8.2-0.62.rc1.el6_9.4.x86_64
---> Package bind-utils.x86_64 32:9.8.2-0.17.rc1.el6 will be updated
---> Package bind-utils.x86_64 32:9.8.2-0.62.rc1.el6_9.4 will be an update
--> Running transaction check
---> Package openssl.x86_64 0:1.0.0-27.el6 will be updated
---> Package openssl.x86_64 0:1.0.1e-57.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package         Arch        Version                         Repository    Size
================================================================================
Installing:
 bind            x86_64      32:9.8.2-0.62.rc1.el6_9.4       updates      4.0 M
Updating:
 bind-libs       x86_64      32:9.8.2-0.62.rc1.el6_9.4       updates      892 k
 bind-utils      x86_64      32:9.8.2-0.62.rc1.el6_9.4       updates      189 k
Updating for dependencies:
 openssl         x86_64      1.0.1e-57.el6                   base         1.5 M

Transaction Summary
================================================================================
Install       1 Package(s)
Upgrade       3 Package(s)

Total download size: 6.6 M
Downloading Packages:
(1/4): bind-9.8.2-0.62.rc1.el6_9.4.x86_64.rpm            | 4.0 MB     00:00     
(2/4): bind-libs-9.8.2-0.62.rc1.el6_9.4.x86_64.rpm       | 892 kB     00:00     
(3/4): bind-utils-9.8.2-0.62.rc1.el6_9.4.x86_64.rpm      | 189 kB     00:00     
(4/4): openssl-1.0.1e-57.el6.x86_64.rpm                  | 1.5 MB     00:00     
--------------------------------------------------------------------------------
Total                                           3.0 MB/s | 6.6 MB     00:02     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : openssl-1.0.1e-57.el6.x86_64                                 1/7 
  Updating   : 32:bind-libs-9.8.2-0.62.rc1.el6_9.4.x86_64                   2/7 
  Updating   : 32:bind-utils-9.8.2-0.62.rc1.el6_9.4.x86_64                  3/7 
  Installing : 32:bind-9.8.2-0.62.rc1.el6_9.4.x86_64                        4/7 
  Cleanup    : 32:bind-utils-9.8.2-0.17.rc1.el6.x86_64                      5/7 
  Cleanup    : 32:bind-libs-9.8.2-0.17.rc1.el6.x86_64                       6/7 
  Cleanup    : openssl-1.0.0-27.el6.x86_64                                  7/7 
  Verifying  : 32:bind-utils-9.8.2-0.62.rc1.el6_9.4.x86_64                  1/7 
  Verifying  : openssl-1.0.1e-57.el6.x86_64                                 2/7 
  Verifying  : 32:bind-libs-9.8.2-0.62.rc1.el6_9.4.x86_64                   3/7 
  Verifying  : 32:bind-9.8.2-0.62.rc1.el6_9.4.x86_64                        4/7 
  Verifying  : 32:bind-utils-9.8.2-0.17.rc1.el6.x86_64                      5/7 
  Verifying  : openssl-1.0.0-27.el6.x86_64                                  6/7 
  Verifying  : 32:bind-libs-9.8.2-0.17.rc1.el6.x86_64                       7/7 

Installed:
  bind.x86_64 32:9.8.2-0.62.rc1.el6_9.4                                         

Updated:
  bind-libs.x86_64 32:9.8.2-0.62.rc1.el6_9.4                                    
  bind-utils.x86_64 32:9.8.2-0.62.rc1.el6_9.4                                   

Dependency Updated:
  openssl.x86_64 0:1.0.1e-57.el6                                                

Complete!
[root@MYDNS etc]# 

4、配置dns主配置文件

文件不需要备份掉:

[root@MYDNS etc]# mv named.conf named.conf_bak
[root@MYDNS etc]# vi named.conf

options {

        directory "/var/named";     // Base directory for named
        allow-transfer {"none";};   // Slave serves that can pull zone transfer. Ban everyone by default

        };

zone "." IN {
        type hint;
        file "named.ca";
};

include "/etc/named.rfc1912.zones";

zone "0.168.192.IN-ADDR.ARPA." IN { // Reverse zone.
        type master;
        notify no;
        file "192.168.0.db";
};

zone "taryartar.com." IN {
        type master;
        notify no;
        file "taryartar.com.db";
};

写入如下内容,保存。

5、进入上面配置的主目录中:

[root@MYDNS etc]# cd /var/named

6、创建正向解析文件

[root@MYDNS named]# vi taryartar.com.db

$TTL 1H         ; Time to live
$ORIGIN  taryartar.com.
@       IN      SOA     mydns  root.taryartar.com.  (
                        2013011201      ; serial (todays date + todays serial #)
                        3H              ; refresh 3 hours
                        1H              ; retry 1 hour
                        1W              ; expire 1 week
                        1D )            ; minimum 24 hour

@       IN              NS  mydns
;
        IN              A 192.168.0.88
mydns           IN A    192.168.0.88
rac1            IN A    192.168.0.51
rac2            IN A    192.168.0.52
rac3            IN A    192.168.0.53
rac4            IN A    192.168.0.54
rac1-vip        IN A    192.168.0.55
rac2-vip        IN A    192.168.0.56
rac3-vip        IN A    192.168.0.57
rac4-vip        IN A    192.168.0.58
myscan          IN A    192.168.0.61
myscan          IN A    192.168.0.62
myscan          IN A    192.168.0.63
rac1-priv1      IN A    10.0.10.1
rac1-priv2      IN A    10.0.10.2
rac2-priv1      IN A    10.0.10.3
rac2-priv2      IN A    10.0.10.4
rac3-priv1      IN A    10.0.10.5
rac3-priv2      IN A    10.0.10.6
rac4-priv1      IN A    10.0.10.7
rac4-priv2      IN A    10.0.10.8
;

7、创建反向解析文件
[root@MYDNS named]# vi 192.168.0.db

$TTL 1H
@       IN      SOA     mydns  root.taryartar.com.  (
                        2013011201      ; serial (todays date + todays serial #)
                        3H              ; refresh 3 hours
                        1H              ; retry 1 hour
                        1W              ; expire 1 week
                        1D )            ; minimum 24 hour
;
                 NS       mydns.taryartar.com.
88      IN      PTR       mydns.taryartar.com.
89      IN      PTR       gnsvip.taryartar.com. ; reverse mapping for GNS
51      IN PTR  rac1.taryartar.com.
52      IN PTR  rac2.taryartar.com.
53      IN PTR  rac3.taryartar.com.
54      IN PTR  rac4.taryartar.com.
55      IN PTR  rac1-vip.taryartar.com.
56      IN PTR  rac2-vip.taryartar.com.
57      IN PTR  rac3-vip.taryartar.com.
58      IN PTR  rac4-vip.taryartar.com.
61      IN PTR  myscan.taryartar.com.
62      IN PTR  myscan.taryartar.com.
63      IN PTR  myscan.taryartar.com.
1       IN PTR  rac1-priv1.taryartar.com.
2       IN PTR  rac1-priv2.taryartar.com.
3       IN PTR  rac2-priv1.taryartar.com.
4       IN PTR  rac2-priv2.taryartar.com.
5       IN PTR  rac3-priv1.taryartar.com.
6       IN PTR  rac3-priv2.taryartar.com.
7       IN PTR  rac4-priv1.taryartar.com.
8       IN PTR  rac4-priv2.taryartar.com.

8、启动dns
[root@MYDNS named]# service named start
Generating /etc/rndc.key:[确定]
启动 named:[确定]
[root@MYDNS named]# ps -ef|grep name
named     2492     1  0 11:22 ?        00:00:00 /usr/sbin/named -u named
root      2500  2015  0 11:22 pts/1    00:00:00 grep name
9、添加开机自启动:
[root@MYDNS named]# chkconfig named on
[root@MYDNS named]# chkconfig --list |grep name
named           0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭
[root@MYDNS named]#

10、配置客户端使用dns服务器

/etc/resolv.conf添加如下内容

[root@MYDNS etc]# vi /etc/resolv.conf

options attempts: 2 
options timeout: 1
search taryartar.com
nameserver 192.168.0.88
11、测试正向解析:
[root@MYDNS etc]# nslookup rac1
Server:         192.168.0.88
Address:        192.168.0.88#53

Name:   rac1.taryartar.com
Address: 192.168.0.51

[root@MYDNS etc]# host rac1
rac1.taryartar.com has address 192.168.0.51
[root@MYDNS etc]# host rac2
rac2.taryartar.com has address 192.168.0.52
[root@MYDNS etc]# host rac1.taryartar.com
rac1.taryartar.com has address 192.168.0.51

12、测试反向解析:
[root@MYDNS etc]# nslookup 192.168.0.52
Server:         192.168.0.88
Address:        192.168.0.88#53

52.0.168.192.in-addr.arpa       name = rac2.taryartar.com.
13、都没问题,ok 原文链接:https://www.f2er.com/centos/375594.html

猜你在找的CentOS相关文章