如何将bind9configuration为只有本地DNS才能访问Internet?

我想configurationbind9只是一个本地DNS,根本就没有互联网接入。 所以我在我的虚拟域xy.com有5台电脑。 在这个领域内没有互联网接入。

DNS服务器具有如下条目:

  • pc1.xy.com IN A 10.1.1.1
  • pc2.xy.com IN A 10.1.1.2
  • pc5.xy.com IN A 10.1.1.5

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

我怎样才能做到这一点?

为了达到这个目的,你需要创build一个假根区域来代替正常configuration的“root.hints”区域。

named.conf放这个:

 zone "." IN { type master; file "fake.root"; }; 

并在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 

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

您也可以将您的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 

除了您可能需要的任何options { } (ACL?)就是这样 – 没有其他要求了。

您需要禁用recursion:

添加到configuration:

allow-transfer {“none”;};

allow-recursion {“none”;};

我的configuration“named.conf”看起来像这样(在RHEL系统上):

 options { allow-query { any; }; allow-recursion { none; }; 

您没有详细描述您的configuration。 我想你错过了权威的一部分。 你需要在你的configuration文件中有这样一个块:

 zone "domain.lan" { type master; file "master/db.domain.lan"; allow-update { none; }; }; 

其中master/db.domain.lan应指向应该包含上面logging的logging的区域文件。 另外,区域文件的标题中应该有SOA(权限的开始)logging。 区域文件应该像这样:

 domain.lan. 86400 IN SOA dns.domain.lan. root.dns.domain.lan. ( 1 10800 3600 6044800 86400 ) 86400 IN NS dns.domain.lan. dns.domain.lan. 86400 IN A 10.10.10.1 pc.domain.lan. 86400 IN A 10.10.10.2 

您可以根据您的需要自定义名称/值/ IP。