我花了很多時間來解決我的問題,但我沒有完成解決此問題所需的工作。
dig ns.insec -t axfr
這是來自主伺服器的錯誤訊息
Mar 16 03:49:30 ip-172-31-22-11 named[5395]: client 127.0.0.1#37251
(ns.insec): zone transfer 'ns.insec/AXFR/IN' denied
這是named.conf.options
文件:
acl "trusted" {
localhost;
172.31.0.0/20;
localnets;
};
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 {
8.8.8.8;
};
//========================================================================
// 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; };
forward only;
allow-query-cache { trusted; };
allow-query { trusted; };
allow-recursion { trusted; };
recursion yes;
allow-transfer { 172.31.31.48; 127.0.0.1; };
//also-notify { trusted; };
};
這是我的named.conf.local
文件:
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
zone "ns.insec" {
type master;
file "/etc/bind/zones/db.ns.insec";
allow-transfer { 172.31.31.48; };
also-notify { 172.31.31.48; };
};
// 172.31.31.48 is the IP for slave
// 172.31.22.11 is the IP for the master
zone "22.31.172.in-addr.arpa" {
type master;
file "/etc/bind/zones/db.172.31.22";
allow-transfer { 172.31.31.48; };
also-notify { 172.31.31.48; };
};
這是主伺服器的檔案權限快照,從伺服器也相同:
N:BI 可以dig ns.insec -t axfr
從伺服器上執行,但不能從主伺服器上執行
答案1
任何選項(在 中)的全域聲明都可以被同一選項的局部聲明(例如在,中)options
覆蓋。zone
view
您的情況也發生了同樣的情況。
您有一個全域選項allow-transfer { 172.31.31.48; 127.0.0.1; };
,該選項被區域定義中的聲明覆蓋zone "ns.insec"
為allow-transfer { 172.31.31.48; };
。因此您將無法將該區域轉移到本機。
zone "ns.insec"
要解決這個問題,請在as中聲明
allow-transfer { 172.31.31.48; 127.0.0.1; };
或者,如果您想使用全域指令(這始終不是一個好主意),請從定義中刪除該allow-transfer
指令。zone "ns.insec"