带 BIND 的通配符 DNS

Jon*_* Wu 19 bind wildcard

我正在尝试设置 BIND,以便它捕获对其发出的所有请求,并将它们指向一组特定的 NS 服务器和特定的 A 记录。

我有大约 500 个域,我以每天 10-15 个的速度添加新域,所以我不想明确地为每个域添加一个区域。

我当前的设置是:在我的 named.conf 中,我有一个视图(名为外部),其中包含以下区域:

zone "." {
        type master;
        file "ext.zone";
};
Run Code Online (Sandbox Code Playgroud)

这匹配所有请求。

ext.zone 是:

3600 美元
@在 SOA 中。root.nsdomain.com。(
                              1 ; 串行
                         3600;刷新
                          300 ; 重试
                         3600;到期
                         300); 负缓存 TTL


        在 NS ns1.example.com
        在 NS ns2.example.com

ns1 IN A 192.0.2.4
ns2 IN A 192.0.2.5

*. 在 192.0.2.6 中

所以,目标是:对于所有 NS 请求,返回ns1.example.comns2.example.com 所有 A 请求,除了它是ns1.example.comor 的地方ns2.example.com,返回192.0.2.6。为了ns1.example.com回报192.0.2.4,为了ns2.example.com回报192.0.2.5

这几乎有效,唯一的问题是当我进行挖掘时,我得到:

挖@localhost somedomain.example

; > DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5_5.3 > @localhost somedomain.example
; (找到 1 个服务器)
;; 全局选项:printcmd
;; 得到答案:
;; 操作码:查询,状态:NOERROR,ID:37733
;; 标志:qr aa rd; 查询:1,答案:1,权威:2,附加:2

;; 问题部分:
;somedomain.example. 在一个

;; 回答部分:
somedomain.example。3600 IN A 192.0.2.6 // 正如预期的那样

;; 权威部分:
. 3600 在 NS ns1.example.com。// 预期,我不知道“。” 不过,一开始很糟糕。
. 3600 在 NS ns2.example.com。// 看上面。

;; 附加部分:
ns1.example.com。3600 IN A 192.0.2.6 // 不是预期的,这应该是 192.0.2.4
ns2.example.com。3600 IN A 192.0.2.6 // 不是预期的,这应该是 192.0.2.5

我该如何解决?我在做可怕的事情吗?有一个更好的方法吗?

Cak*_*mox 17

您的区域来源.取决于您的配置。您正在为ns1.andns2.而不是ns1.example.com.and创建记录ns2.example.com. 由于ns1.example.com并且ns2.example.com未定义,它们由通配符匹配。

编辑:这是您的配置和区域的编辑:

zone "example.com." {
        type master;
        file "ext.zone";
};
Run Code Online (Sandbox Code Playgroud)

扩展区:

$TTL    3600
@       IN      SOA     ns1 root (
                              1         ; Serial
                         3600         ; Refresh
                          300         ; Retry
                         3600         ; Expire
                         300 )        ; Negative Cache TTL


        IN      NS      ns1
        IN      NS      ns2
        IN      A       192.0.2.6


ns1     IN      A       192.0.2.4
ns2     IN      A       192.0.2.5

*      IN      A       192.0.2.6
Run Code Online (Sandbox Code Playgroud)

区域中的所有内容都与命名配置中的区域名称相关,因此添加第二个区域只需指向同一个文件:

zone "example.net." {
    type master;
    file "ext.zone";
};
Run Code Online (Sandbox Code Playgroud)


Ped*_*ito 6

要设置子域通配符,bind应使用以下格式:

name.tld.   IN  A   IP    # main domain ip
*.name.tld. IN  A   IP    # wildcard subdomains ip
Run Code Online (Sandbox Code Playgroud)

例子:

mydomain.com.   IN  A   1.1.1.1
*.mydomain.com. IN  A   1.1.1.1 
Run Code Online (Sandbox Code Playgroud)