大网数据广告活动
服务器运维问答

Bind9 newbie not able to resolve local addresses

· 52CE 我爱测

I am completely new to DNS servers and as an educational tool, I have installed bind9 on a RPi running dietpi - a stripped down version of Debian. External addresses resolve perfectly but internal ones do not. I have a db.local.l…

问题原文

原帖链接 · DigitalKiwi · CC BY-SA 4.0

I am completely new to DNS servers and as an educational tool, I have installed bind9 on a RPi running dietpi - a stripped down version of Debian.

External addresses resolve perfectly but internal ones do not. I have a db.local.lan file set up like this:

$TTL 3D 
$ORIGIN local.lan. 
local.lan. IN SOA dietpi.local.lan. hostmaster.local.lan. ( 
        2020100418 ; serial 
        8H ; refresh 
        4H ; retry 
        4W ; expire 
        1D ; minimum 
    ) 
    local.lan. IN NS dietpi.local.lan. 
    local.lan. IN MX 10 dietpi.local.lan. 
    localhost IN A 127.0.0.1 
    dietpi IN A 192.168.20.254 
    router IN A 192.168.20.1 
    NL1901ACV IN A 192.168.20.1

named.conf.local is like this:

//
// Do any local configuration here
//

zone "local.lan" IN {
            type master;
            file "/etc/bind/db.local.lan";
      };
    zone "20.168.192.in-addr.arpa" {
            type master;
            file "/etc/bind/db.rev.20.168.192.in-addr.arpa";
      };

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

I have a pc set up to use this device as it's dns server. from this pc I can ping google.com, but if I try to ping dietpi or dietpi.local.lan I get a host not found error.

named-checkconf reveals no errors.

named-checkconf -z returns the following - I have no idea what this means!

/etc/bind/db.local.lan:10: unknown RR type 'local.lan.'
/etc/bind/db.local.lan:11: unknown RR type 'local.lan.'
/etc/bind/db.local.lan:12: unknown RR type 'localhost'
/etc/bind/db.local.lan:13: unknown RR type 'dietpi'
/etc/bind/db.local.lan:14: unknown RR type 'router'
/etc/bind/db.local.lan:15: unknown RR type 'NL1901ACV'
zone local.lan/IN: loading from master file /etc/bind/db.local.lan failed: unknown class/type
zone local.lan/IN: not loaded due to errors.
_default/local.lan/IN: unknown class/type
/etc/bind/db.rev.20.168.192.in-addr.arpa:1: no TTL specified; using SOA MINTTL instead
/etc/bind/db.rev.20.168.192.in-addr.arpa:10: TTL set to prior TTL (1)
zone 20.168.192.in-addr.arpa/IN: loaded serial 2020100417
zone localhost/IN: loaded serial 2
zone 127.in-addr.arpa/IN: loaded serial 1
zone 0.in-addr.arpa/IN: loaded serial 1
zone 255.in-addr.arpa/IN: loaded serial 1

Can anyone explain what I am doing wrong?

Thanks in advance. David.

已采纳解答

原帖链接 · Lacek · CC BY-SA 4.0

Remove the spaces from the beginnning of the host entries in the zone file.

The problem here is if a line starts with a whitespace, then the line is supposed to refer to the previous entry. In this case, you should not specify the name, because it is already given. Also, you don't need the INs in the zone file.

This zone file should work:

$TTL 3D 
$ORIGIN local.lan. 
local.lan. IN SOA dietpi.local.lan. hostmaster.local.lan. ( 
    2020100418 ; serial 
    8H ; refresh 
    4H ; retry 
    4W ; expire 
    1D ; minimum 
) 
   NS dietpi.local.lan. 
   MX 10 dietpi.local.lan. 
localhost A 127.0.0.1 
dietpi A 192.168.20.254 
router A 192.168.20.1 
NL1901ACV A 192.168.20.1

Notice that the first two entries have spaces at the beginning. This makes the entries refer to the previous entry, i.e. the zone itself. Since this reference is given by the leading blank in the line, no name should be specified in those entries. The entries in the rest of the file refer to separate records, so they do have a name, and don't have a leading space.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-10-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。