如何将 bind9 配置为仅本地 DNS 且无法访问 Internet?

Joh*_*mBF 6 domain-name-system local-area-network internet bind reverse-dns

我想将 bind9 配置为本地 DNS,但根本无法访问互联网。所以我的虚拟域 xy.com 中有 5 台 PC。在此域中,无法访问 Internet。

DNS 服务器具有以下条目:

  • 10.1.1.1 中的 pc1.xy.com
  • 10.1.1.2 中的 pc2.xy.com
  • .
  • .
  • 10.1.1.5 中的 pc5.xy.com

绑定配置正确,但是当我在 DNS 服务器上执行“dig @localhost pc1”时它不起作用,因为他卡在联系根服务器上。但我只希望他是本地人并回答 pc1 有哪个 IP。

我怎样才能做到这一点?

Aln*_*tak 9

为此,您需要创建一个假的根区域来替换通常配置的“root.hints”区域。

named.conf把这个:

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

fake.root把这个:

$TTL    300
.               IN      SOA ns. hostmaster.xy.com. (
                        20120101 1800 900 604800 86400
                )
.               IN      NS      ns
ns              IN      A       127.0.0.1
Run Code Online (Sandbox Code Playgroud)

这将阻止所有尝试访问互联网以获取真正的根提示。

您也可以将您的pcN.xy.com条目直接放入该根区域 - 它们不需要位于自己的xy.com区域文件中,因此您只需将以下内容附加到fake.root

$ORIGIN xy.com.
pc1             IN      A       10.1.1.1
pc2             IN      A       10.1.1.2
pc3             IN      A       10.1.1.3
pc4             IN      A       10.1.1.4
pc5             IN      A       10.1.1.5
Run Code Online (Sandbox Code Playgroud)

除了options { }您可能需要的任何东西(ACL?)就是这样 - 不需要其他任何东西。