智能DNS实现

原理:

        智能DNS也就是能够根据某些特征自动实现智能的DNS解析,可以根据IP段或者是运营商,地区等信息来控制DNS解析的指向,从而实现智能的,合理高效的域名解析。

一、 环境:

Linux OS:Centos-6.6

IP地址:210.38.248.xxx

二、 安装和配置bind服务:

配置:

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.first和a.org.second文件并配置:

配置:

配置a.org.first如下:

$TTL 1200

$ORIGIN a.org.

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

2014091301

6H

30M

15D

3D)

INNS ns1.a.org.

INNS ns2.a.org.

INMX10 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)

INNS ns1.a.org.

INNS ns2.a.org.

INMX10 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目录:

重启:

service named restart

三、测试

// 分别在240/248网段的电脑终端上使用命令:

声明:文中观点不代表本站立场。本文传送门:https://eyangzhen.com/235132.html

联系我们
联系我们
分享本页
返回顶部