• [原创]CentOS实现智能DNS


    一、       环境:

    Centos-6.6-x64位操作系统,IP地址:210.38.248.7

    二、       安装和配置bind服务:

      1.      命令:yum install bind

      2.      配置:

    1)  配置/etc/named.conf文件:

    acl ip1{

            210.38.240.0/24;              //定义240网段

    };

    acl ip2{

            210.38.248.0/24;              //定义248网段

    };

    options {

            directory       "/var/named";              //服务安装目录

            recursion yes;            //是否开启DNS递归

    };

    view "first"{

            match-clients {ip1;};   //匹配240网段

            recursion yes;

            zone "." IN {

                    type hint;

                    file "named.ca";

            };

            zone "a.org" IN {

                    type master;

                    file "a.org.first";

            };

    zone "1.168.192.in-addr.arpa" IN {

                    type master;

                    file "1.168.192";

            };

    };

    view "second"{

            match-clients {ip2;};         //匹配248网段

                    recursion no;

            zone "." IN {

                    type hint;

                    file "named.ca";

            };

            zone "a.org" IN {

                    type master;

                    file "a.org.second";

            };

    zone "5.168.192.in-addr.arpa" IN {

                    type master;

                    file "5.168.192";

            };

    };

    2)  建立a.org.firsta.org.second文件并配置:

    ->创建: touch a.org.first

                        Touch a.org.second

    ->配置:

    配置a.org.first如下:

    $TTL 1200

    $ORIGIN a.org.

    @       IN      SOA     ns1.a.org.      admin.a.org.(

                                            2014091301

                                            6H

                                            30M

                                            15D

                                            3D)

            IN      NS      ns1.a.org.

            IN      NS      ns2.a.org.

            IN      MX 10   mail.a.org.

    ns1     IN      A       192.168.1.5

    ns2     IN      A       192.168.1.6

    mail    IN      A       192.168.1.7

    www     IN      A       192.168.1.8

    配置a.org.second如下:

    $TTL 1200

    $ORIGIN a.org.

    @       IN      SOA     ns1.a.org.      admin.a.org.(

                                            2014091301

                                            6H

                                            30M

                                            15D

                                            3D)

            IN      NS      ns1.a.org.

            IN      NS      ns2.a.org.

            IN      MX 10   mail.a.org.

    ns1     IN      A       192.168.5.5

    ns2     IN      A       192.168.5.6

    mail    IN      A       192.168.5.7

    www     IN      A       192.168.5.8

    配置1.168.192如下:

    $TTL 86400

    @          IN     SOA  ns1.a.org.         admin.a.org.(

                                            2014091301

                                            6H

                                            30M

                                            15D

                                            3D)

                  IN     NS              ns1.a.org.

                  IN     PTR  a.org.

    5            IN     PTR  ns1.a.org.

    6            IN     PTR  ns2.a.org.

    7            IN     PTR  mail.a.org.

    8            IN     PTR  www.a.org

    配置5.168.192如下:

    $TTL 86400

    @          IN     SOA  ns1.a.org.         admin.a.org.(

                                            2014091301

                                            6H

                                            30M

                                            15D

                                            3D)

                  IN     NS              ns1.a.org.

                  IN     PTR  a.org.

    5            IN     PTR  ns1.a.org.

    6            IN     PTR  ns2.a.org.

    7            IN     PTR  mail.a.org.

    8            IN     PTR  www.a.org

                               ->拷贝文件到/var/named目录:

                                         #cp a.org.* /var/named

                                         #cp 1.168.192 /var/named

                                         #cp 5.168.192 /var/named

    3.      重启:service named restart

    三、测试:分别在240/248网段的电脑终端上使用命令:nslookup ns1.a.org(域名)测试,查看解析的IP地址。

  • 相关阅读:
    jdk和jre有什么区别?
    Apache的作用及意义
    博客园新成员的第一天
    重构改善既有代码的设计--简化条件表达式
    SourceMonitor: 代码重构的小工具,大用场
    使用Eclipse中提供的Refactor(重构)工具
    极大提高Web开发效率的8个工具和建议(含教程)
    Hbase shell命令
    Java多线程-新特性-有返回值的线程
    Java多线程-新特征-条件变量
  • 原文地址:https://www.cnblogs.com/wsjhk/p/4589433.html
Copyright © 2020-2023  润新知