以下是我的 BIND9 配置。我要配置的域是home.lan
。它是家庭网络。
/etc/bind/named.conf.local
是:
zone "home.lan" IN {
type master;
file "/etc/bind/zones/home.lan.db";
};
zone "1.168.192.in-addr.arpa" {
type master;
file "/etc/bind/zones/rev.1.168.192.in-addr.arpa";
};
/etc/bind/named.conf.options
是:
options {
directory "/var/cache/bind";
// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113
// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.
// forwarders {
// 0.0.0.0;
// };
//========================================================================
// If BIND logs error messages about the root key being expired,
// you will need to update your keys. See https://www.isc.org/bind-keys
//========================================================================
dnssec-validation auto;
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
};
因为它是一个个人网络,我不需要任何转发器部分,所以没有配置它。
/etc/bind/zones/home.lan.db
; Use semicolons to add comments.
; Host-to-IP Address DNS Pointers for home.lan
; Note: The extra “.” at the end of the domain names are important.
; The following parameters set when DNS records will expire, etc.
; Importantly, the serial number must always be iterated upward to prevent
; undesirable consequences. A good format to use is YYYYMMDDII where
; the II index is in case you make more that one change in the same day.
$ORIGIN .
$TTL 86400 ; 1 day
home.lan. IN SOA ubuntu.home.lan. hostmaster.home.lan. kalu.home.lan. (
2008080901 ; serial
8H ; refresh
4H ; retry
4W ; expire
1D ; minimum
)
; NS indicates that ubuntu is the name server on home.lan
; MX indicates that ubuntu is (also) the mail server on home.lan
home.lan. IN NS kalu.home.lan.
home.lan. IN MX 10 ubuntu.home.lan.
$ORIGIN home.lan.
; Set the address for localhost.home.lan
localhost IN A 127.0.0.1
; Set the hostnames in alphabetical order
home IN A 192.168.1.7
ntinstall IN A 192.168.1.7
kalu IN A 192.168.1.7
router IN A 192.168.1.1
server IN A 192.168.1.5
和/etc/bind/zones/rev.1.168.192.in-addr.arpa
:
; IP Address-to-Host DNS Pointers for the 192.168.1 subnet
@ IN SOA ubuntu.home.lan. hostmaster.home.lan. (
2008080901 ; serial
8H ; refresh
4H ; retry
4W ; expire
1D ; minimum
)
; define the authoritative name server
IN NS ubuntu.home.lan.
; our hosts, in numeric order
1 IN PTR router.home.lan.
2 IN PTR ubuntu.home.lan.
3 IN PTR ntinstall.home.lan.
4 IN PTR kalu.home.lan.
/etc/hostnames
:
kalu
/etc/resolv.conf
BIND9 服务器上的内容是:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1
search home.lan
at the client machine
/etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1
nameserver 192.168.1.7
search home.lan
当我尝试从客户端机器 ping 时,我得到以下结果:
$ ping kalu.home.lan
ping: unknown host kalu.home.lan
没有类似的文件/var/log/bind.log
,所以我不确定在哪里可以找到它。
这是dig
服务器的输出:
挖掘 kalu.home.lan
; <<>> DiG 9.8.1-P1 <<>> kalu.home.lan
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 36937
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;kalu.home.lan. IN A
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Oct 11 23:59:03 2013
;; MSG SIZE rcvd: 31
在客户端机器上dig kalu.home.lan
给出以下结果:
dig kalu.home.lan
; <<>> DiG 9.8.1-P1 <<>> kalu.home.lan
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 25537
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;kalu.home.lan. IN A
;; AUTHORITY SECTION:
. 7388 IN SOA a.root-servers.net. nstld.verisign-grs.com. 2013101101 1800 900 604800 86400
;; Query time: 43 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Oct 11 23:59:34 2013
;; MSG SIZE rcvd: 106
上述 DNS 配置中的错误是什么?
kalu
是我正在配置所有这些的机器的主机名。
要在 BIND9 中启用日志记录,rndc querylog
它会显示:
Oct 12 01:42:16 ubuntu named[11408]: dns_rdata_fromtext: /etc/bind/zones/home.lan.db:11: near 'kalu.home.lan.': not a valid number
Oct 12 01:42:16 ubuntu named[11408]: zone home.lan/IN: loading from master file /etc/bind/zones/home.lan.db failed: not a valid number
Oct 12 01:42:16 ubuntu named[11408]: zone home.lan/IN: not loaded due to errors.
Oct 12 01:42:16 ubuntu named[11408]: zone localhost/IN: loaded serial 2
Oct 12 01:42:16 ubuntu named[11408]: managed-keys-zone ./IN: loaded serial 5
我看到:
sudo named-checkzone home.lan home.lan.db
[sudo] password for hp:
zone home.lan/IN: loading from master file home.lan.db failed: file not found
zone home.lan/IN: not loaded due to errors.
答案1
home.lan.db
文件“ ”和“ ”的 IPrev.1.168.192.in-addr.arpa
不匹配。只需更正它们即可。
/etc/bind/zones/home.lan.db
; Set the hostnames in alphabetical order
home IN A 192.168.1.7
ntinstall IN A 192.168.1.7
kalu IN A 192.168.1.7
router IN A 192.168.1.1
server IN A 192.168.1.5
/etc/bind/zones/rev.1.168.192.in-addr.arpa
; our hosts, in numeric order
1 IN PTR router.home.lan.
2 IN PTR ubuntu.home.lan.
3 IN PTR ntinstall.home.lan.
4 IN PTR kalu.home.lan.
############
# For example, the correct one should be:
/etc/bind/zones/home.lan.db
; Set the hostnames in alphabetical order
kalu IN A 192.168.1.4
ntinstall IN A 192.168.1.3
router IN A 192.168.1.1
ubuntu IN A 192.168.1.2
/etc/bind/zones/rev.1.168.192.in-addr.arpa
; our hosts, in numeric order
1 IN PTR router.home.lan.
2 IN PTR ubuntu.home.lan.
3 IN PTR ntinstall.home.lan.
4 IN PTR kalu.home.lan.