设置合并 Google DNS 和 OpenNIC 的本地 DNS 服务器

设置合并 Google DNS 和 OpenNIC 的本地 DNS 服务器

我想在我的本地计算机上设置 bind9,这样常见的 dns 查询(例如 com、de、net)就会转发到 Google DNS,而其他来自 OpenNic 的定制查询(例如 bbs、dyn、free)则会转发到 OpenNIC-DNS 服务器。

dns 服务器不应该进行缓存或从 OpenNIC-DNS 服务器下载所有区域文件。

你能帮助我吗?

这是我的不起作用的配置:

//named.conf:
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

//named.conf.default-zones
zone "localhost" {
    type master;
    file "/etc/bind/db.local";
};

zone "127.in-addr.arpa" {
    type master;
    file "/etc/bind/db.127";
};

zone "0.in-addr.arpa" {
    type master;
    file "/etc/bind/db.0";
};

zone "255.in-addr.arpa" {
    type master;
    file "/etc/bind/db.255";
};

// named.conf.local:
// replace all '...' with the following:
//      type forward;
//      forwarders {78.138.98.82; 78.138.97.33;};
//      forward only;
zone "dns.opennic.glue" in { ... };
zone "bbs" in { ... };
zone "dyn" in { ... };
zone "free" in { ... };
zone "fur" in { ... };
zone "geek" in { ... };
zone "gopher" in { ... };
zone "indy" in { ... };
zone "ing" in { ... };
zone "micro" in { ... };
zone "neo" in { ... };
zone "null" in { ... };
zone "opennic.glue" in { ... };
zone "oss" in { ... };
zone "oz" in { ... };
zone "parody" in { ... };
zone "pirate" in { ... };

// named.conf.options
options {
    directory "/var/cache/bind";
    forwarders { 8.8.8.8; 8.8.4.4; };
    forward only;
    dnssec-validation auto;
    auth-nxdomain no;
};

以下是 google.com 和 grep.geek 的 traceroute 输出:

# tracerout google.com
traceroute to google.com (173.194.116.192), 64 hops max
 1   192.168.178.1 (192.168.178.1) 1.436ms 1.195ms 1.195ms 
 2   80.69.104.84 (80.69.104.84) 10.818ms 9.268ms 16.093ms 
 3   *  *  * 
 4   72.14.213.197 (72.14.213.197) 41.229ms 36.026ms 36.034ms 
 5   72.14.238.46 (72.14.238.46) 11.824ms 9.628ms 9.822ms 
 6   66.249.94.143 (66.249.94.143) 12.487ms 17.118ms 19.893ms 
 7   173.194.116.192 (173.194.116.192) 10.171ms 9.559ms 9.874ms

traceroute grep.geek
traceroute to hit-nxdomain.opendns.com (67.215.65.132), 64 hops max
 1   192.168.178.1 (192.168.178.1) 2.605ms 2.242ms 1.218ms 
 2   80.69.104.84 (80.69.104.84) 9.502ms 11.883ms 13.299ms 
 3   80.69.105.209 (80.69.105.209) 9.645ms 9.366ms  * 
 4   80.69.107.214 (80.69.107.214) 13.783ms 11.845ms 12.632ms 
 5   80.69.107.21 (80.69.107.21) 15.165ms 17.931ms 23.894ms 
 6   80.69.107.209 (80.69.107.209) 16.423ms 21.342ms 18.070ms 
 7   80.69.107.9 (80.69.107.9) 21.847ms 19.817ms 19.860ms 
 8   84.116.197.253 (84.116.197.253) 32.887ms 40.201ms 36.557ms 
 9   84.116.133.230 (84.116.133.230) 36.050ms 31.760ms 31.942ms 
10   195.66.225.70 (195.66.225.70) 31.176ms 30.835ms 30.011ms 
11   67.215.65.132 (67.215.65.132) 34.920ms 34.592ms 42.566ms

答案1

我找到了我的 DNS 服务器无法正常工作的原因。

在 named.conf.options 中 dnssec-validation 必须设置为 no,否则 opennic 的 dns 服务器将被忽略:

// named.conf.options
options {
    directory "/var/cache/bind";
    forwarders { 8.8.8.8; 8.8.4.4; };
    forward only;
    dnssec-validation no;
    auth-nxdomain no;
};

解决方案已在以下网址找到:https://serverfault.com/questions/413600/bind-9-7-3-not-forwarding-to-isp-dns-server-only-local-resolving-successful

相关内容