DNS - 使用公共域名供内部使用

Rap*_*lis 2 domain-name-system bind internal-dns dns-zone

我已将 Bind 设置为我的 Intranet DNS 解析服务(在 Ubuntu 16.04.02 LTS 上运行)。

我想要实现的目标: 拥有指向服务器的公共域名(例如:domain.com -> 1.2.3.4)使用指向内部机器的相同子域名(例如:machine1.domain.com -> 192.168。 1.100)

我所做的:(配置)

文件:/etc/bind/named.conf.options

options {
    directory "/var/cache/bind";

    recursion yes;
    allow-recursion { 192.168.2.0/24; };
    listen-on {192.168.2.4; };
    allow-transfer { none; };

    forwarders {
            192.168.2.1; #router
            8.8.8.8; #public dns
    };

    dnssec-validation auto;
    auth-nxdomain no;    # conform to RFC1035
    listen-on-v6 { any; };
};

    acl "truested" {
            192.168.2.0/24;
            192.168.2.4; # ns1
            192.168.2.5; # ns2
};
Run Code Online (Sandbox Code Playgroud)

文件:/etc/bind/named.conf.local

zone "domain.com" {
    type master;
    file "/etc/bind/zones/db.domain.com";
    allow-transfer { 192.168.2.5;};
};

zone 2.168.192.in-addr.arpa {
    type master;
    file "/etc/bind/zones/db.2.168.192";
    allow-transfer { 192.168.2.5; };
};
Run Code Online (Sandbox Code Playgroud)

文件:/etc/bind/zones/db.domain.com

$TTL    604800
@       IN      SOA     ns1.domain.com. root.domain.com. (
                          5         ; Serial
                     604800         ; Refresh
                      86400         ; Retry
                    2419200         ; Expire
                     604800 )       ; Negative Cache TTL
; name servers - NS Records
    IN      NS      ns1.domain.com.
    IN      NS      ns2.domain.com.

; name servers - A Records
ns1.domain.com. IN      A       192.168.2.4
ns2.domain.com. IN      A       192.168.2.5

; 192.168.2.0/24 - A Records
server.domain.com.      IN      A       192.168.2.120
server2.domain.com.     IN      A       192.168.2.121
ns1.domain.com.         IN      A       192.168.2.4
ns2.domain.com.         IN      A       192.168.2.5
Run Code Online (Sandbox Code Playgroud)

文件:/etc/bind/zones/db.2.168.192

$TTL    604800
@       IN      SOA     ns1.domain.com. root.domain.com. (
                          4         ; Serial
                     604800         ; Refresh
                      86400         ; Retry
                    2419200         ; Expire
                     604800 )       ; Negative Cache TTL
; name servers - NS Records
    IN      NS      ns1.domain.com.
    IN      NS      ns2.domain.com.

;       PTR Records
4       IN      PTR     ns1.domain.com.
5       IN      PTR     ns2.domain.com.
120     IN      PTR     server.domain.com.
121     IN      PTR     server2.domain.com.
Run Code Online (Sandbox Code Playgroud)

问题:当我从计算机(已将此服务器“192.168.2.4”设置为 DNS 服务器)为domain.com的 IP 执行 DNS 查找时,它不会返回值。因此不会打开外部网页服务器(domain.com)。

我需要更改什么才能让 DNS 服务器按我的意愿工作?

pou*_*toi 5

为什么不为domain.com的区域设置转发并为本地名称服务器对其具有权威性的domain.com的子域创建一个新区域?

我的示例使用example.com而不是domain.com ...

                                   192.168.33.0/24                               
+-------------------------+ |                                     
| | |                                     
| 客户端 1 |192.168.33.1 | +----------------------+
| client1.corp.example.com |-------------- | |
| | |192.168.33.5 | 企业名称服务器|
+-------------------------+ ---------------| ns1.corp.example.com |
                                         | | |
                                         | +----------------------+
+-------------------------+ |                                     
| | |                                     
|服务器 1 | 192.168.33.2 |                                     
|server1.corp.example.com |--------------|                                     
| | | +------------+          
+-------------------------+ |192.168.33.7 | |          
                                         --------------- 路由器|          
                                         | | |          
                                         | +------|-----+          
                                         | |                
                                                              |                
                                                              |1.2.3.4         
                                                              |                
                                                              |                

                                                         互联网          
                                       1.2.3.5 /-----                       
                                   /-------------- |               
                +----------------- |               
                | | | 1.2.3.6       
                | 万维网服务器 | |               
                | www.example.com | +------------|------------+  
                | | | |  
                +---+ | example.com 名称服务器 |  
                                                  | ns.example.com |  
                                                  | |  
                                                  +-------------------------+

以下是配置:

/etc/bind/named.conf.options

选项 {
    目录“/var/cache/bind”;

    dnssec 验证自动;

    auth-nxdomain 没有;
};

/etc/bind/named.conf.local

区域“example.com”{
    向前输入;
    货代{
        1.2.3.6;
    };
};

区域“corp.example.com”{
    类型大师;
    文件“/etc/bind/db.corp.example.com”;
};

区域 33.168.192.in-addr.arpa {
    类型大师;
    文件“/etc/bind/db.192.168.33”;
};

/etc/bind/db.db.corp.example.com

                                       
$TTL 604800
$ORIGIN corp.example.com。

@ IN SOA ns1.corp.example.com。admin.example.com。(
                        5;         
                        604800;
                        86400;   
                        2419200;
                        604800;
                        )

; 名称服务器
        在 NS ns1.corp.example.com 中。

; 名称服务器
ns1 输入 192.168.33.5

; 主机
客户端 1 输入 192.168.33.1
server1 IN A 192.168.33.2
ns1 输入 192.168.33.5

/etc/bind/db.192.168.33

$TTL 604800
$ORIGIN 33.168.192.in-addr.arpa。

@ IN SOA ns1.corp.example.com。admin.example.com。(
                        4;
                        604800;
                        86400;
                        2419200;
                        604800;
                        )
; 名称服务器
        在 NS ns1.corp.example.com 中。

; 主机
1 在 PTR client1.corp.example.com。
2 在 PTR server1.corp.example.com 中。
5 在 PTR ns1.corp.example.com。

注意:您在db.2.168.192区域文件中缺少$ORIGIN指令,但您在 PTR RR 中使用了快捷方式。

本地安装 BIND 的 Nslookup 测试(转发到8.8.8.8 for zone example.com只是为了我们可以得到一些结果):

> 服务器 127.0.0.1
默认服务器:127.0.0.1
地址:127.0.0.1#53
> 设置类型=ns
> corp.example.com
服务器:127.0.0.1
地址:127.0.0.1#53

corp.example.com 名称服务器 = ns1.corp.example.com。
> 设置类型=a
> server1.corp.example.com
服务器:127.0.0.1
地址:127.0.0.1#53

名称:server1.corp.example.com
地址:192.168.33.2

而对于www.example.com

> 设置类型=a
> www.example.com
服务器:127.0.0.1
地址:127.0.0.1#53

非权威回答:
名称:www.example.com
地址:93.184.216.34