IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    DNS编程开发(7)—bind场景测试之type/view/泛域名

    cjhust发表于 2015-06-16 17:39:22
    love 0

    1、测试结论

    场景1

    server1. eyuyao.com. GANSU IN A 10.1.1.1

    *. eyuyao.com. DEFAULT IN CNAME www.taobao.com

    (1)dig server1. eyuyao.com. A +subnet=GANSU:返回A记录10.1.1.1;

    (2)dig server1. eyuyao.com. MX +subnet=GANSU:返回SOA+NOERROR;

    (3)dig server1. eyuyao.com. A +subnet=OTHER:返回CNAME;

    (4)dig server1. eyuyao.com. MX +subnet=OTHER:返回CNAME;

    (5)dig other. eyuyao.com. A +subnet=GANSU:返回SOA+NXDOMAIN;

    (6)dig other. eyuyao.com. MX +subnet=GANSU:返回SOA+NXDOMAIN;

    (7)dig other. eyuyao.com. A +subnet=OTHER:返回CNAME;

    (8)dig other. eyuyao.com. MX +subnet=OTHER:返回CNAME;

    场景2

    test.bug.com. default 600 IN A 1.1.1.1

    *.bug.com. default 600 IN CNAME www.cname.com.

    (1)dig test.bug.com. A:返回A记录1.1.1.1;

    (2)dig test.bug.com. MX:返回SOA+NOERROR;

    (3)dig other.bug.com. A:返回CNAME;

    (4)dig other.bug.com. MX:返回CNAME;

    2、测试案例

    acllist.conf(公共配置)

    acl "gansu" {

    1.1.1.1;

    };

    acl "hubei" {

    2.2.2.2;

    };

    named-acl.conf(公共配置)

    include "etc/acllist.conf";

    key "rndckey" {

    algorithm hmac-md5;

    secret "QFbp0H8FsqaD+Oct6TYYlg==";

    };

    controls {

    inet 127.0.0.1 port 953

    allow { 127.0.0.1; } keys { "rndckey"; };

    };

    logging {

    channel query_log {

    file "/home/jie.cj/named/logs/namequery.log" versions 3 size 20m;

    severity info;

    print-time yes;

    print-category yes;

    };

    category queries {

    query_log;

    };

    channel update_log {

    file "/home/jie.cj/named/logs/nameupdate.log" versions 3 size 5m;

    severity info;

    print-time yes;

    print-category yes;

    };

    category update {

    update_log;

    };

    channel general_log {

    file "/home/jie.cj/named/logs/namegeneral.log" versions 3 size 5m;

    severity info;

    print-time yes;

    print-category yes;

    };

    category general {

    general_log;

    };

    };

    options {

    recursion no;

    directory "/home/jie.cj/named/zones/";

    pid-file "named.pid";

    };

    view "gansu" { #IP 1.1.1.1

    match-clients {gansu;};

    zone "eyuyao.com" IN {

    type master;

    file "views/eyuyao.zone.gansu";

    allow-update { none; };

    };

    };

    view "default" {

    match-clients {any;};

    zone "eyuyao.com" IN {

    type master;

    file "views/eyuyao.zone.default";

    allow-update { none; };

    };

    };

    备注:#./sbin/named -gc etc/named-acl.conf -n 10。

    3、测试场景

    场景1—指定域名存在某个view,泛域名存在default

    server1. eyuyao.com. GANSU IN A 10.1.1.1

    *. eyuyao.com. DEFAULT IN CNAME www.taobao.com

    (1)dig server1. eyuyao.com. A +subnet=GANSU:返回A记录10.1.1.1;

    (2)dig server1. eyuyao.com. MX +subnet=GANSU:返回SOA+NOERROR;

    (3)dig server1. eyuyao.com. A +subnet=OTHER:返回CNAME;

    (4)dig server1. eyuyao.com. MX +subnet=OTHER:返回CNAME;

    (5)dig other. eyuyao.com. A +subnet=GANSU:返回SOA+NXDOMAIN;

    (6)dig other. eyuyao.com. MX +subnet=GANSU:返回SOA+NXDOMAIN;

    (7)dig other. eyuyao.com. A +subnet=OTHER:返回CNAME;

    (8)dig other. eyuyao.com. MX +subnet=OTHER:返回CNAME;

    eyuyao.zone.gansu

    @ IN SOA eyuyao.com. root.eyuyao.com. (

    1053891162

    3H

    15M

    1W

    1D )

    IN NS ns

    ns IN A 1.1.1.1

    server1 IN A 10.1.1.1

    eyuyao.zone.default

    @ IN SOA eyuyao.com. root.eyuyao.com. (

    1053891162

    3H

    15M

    1W

    1D )

    IN NS ns

    ns IN A 1.1.1.1

    * IN CNAME www.taobao.com.

    dig指定域名—A记录

    # dig server1.eyuyao.com +subnet=gansu

    image

    # dig server1.eyuyao.com +subnet=other

    image

    备注:因为bind是view->zone->node->rdata的架构,当subnet=other的时候,进入的是default view。

    dig指定域名—type记录

    # dig server1.eyuyao.com MX +subnet=gansu(返回NOERROR)

    image

    # dig server1.eyuyao.com MX +subnet=other

    image

    备注:因为bind是view->zone->node->rdata的架构,当subnet=other的时候,进入的是default view,当subnet=gansu的时候,由于node存在,MX记录不存在,因此返回SOA+NOERROR。

    dig其他域名—A记录

    # dig other.eyuyao.com +subnet=gansu(返回NXDOMAIN)

    image

    # dig other.eyuyao.com +subnet=other

    image

    备注:因为bind是view->zone->node->rdata的架构,当subnet=other的时候,进入的是default view,当subnet=gansu的时候,由于node不存在,因此返回SOA+NXDOMAIN。

    dig其他域名—type记录

    # dig other.eyuyao.com MX +subnet=gansu(返回NXDOMAIN)

    image

    # dig other.eyuyao.com MX +subnet=other

    image

    备注:因为bind是view->zone->node->rdata的架构,当subnet=other的时候,进入的是default view,当subnet=gansu的时候,由于node不存在,因此返回SOA+NXDOMAIN。

    场景2—泛域名和指定域名指定类型存在default

    test.bug.com. default 600 IN A 1.1.1.1

    *.bug.com. default 600 IN CNAME www.cname.com.

    (1)dig test.bug.com. A:返回A记录1.1.1.1;

    (2)dig test.bug.com. MX:返回SOA+NOERROR;

    (3)dig other.bug.com. A:返回CNAME;

    (4)dig other.bug.com. MX:返回CNAME;

    named-acl.conf

    view "default" {

    match-clients {any;};

    zone "bug.com" IN {

    type master;

    file "bug.zone";

    allow-update { none; };

    }

    };

    备注:一旦使用了view语句,所有的zone就必须配置到views中。

    image

    bug.zone

    @ IN SOA bug.com. root.bug.com. (

    1053891162

    3H

    15M

    1W

    1D )

    @ IN NS dns.bug.com.

    dns IN A 1.1.1.1

    test IN A 10.2.2.2

    * IN CNAME www.taobao.com.

    dig指定域名—A记录

    # dig test.bug.com

    image

    dig指定域名—type记录

    # dig test.bug.com MX

    image

    备注:因为bind是view->zone->node->rdata的架构,当node存在,类型不存在的时候,返回SOA+NOERROR。

    dig其他域名—A记录

    # dig other.bug.com A

    image

    备注:因为bind是view->zone->node->rdata的架构,当node不存在的时候,查找泛域名。

    dig其他域名—type记录

    # dig other.bug.com MX

    image

    备注:因为bind是view->zone->node->rdata的架构,当node不存在的时候,查找泛域名。



沪ICP备19023445号-2号
友情链接