我有一個 BIND ubuntu 伺服器作為com
區域和兩個主機(Web 伺服器)的私人 DNS 伺服器。三者是使用virtual box的虛擬主機,並使用虛擬主機卡連接在一起。
我在 DNS 伺服器中有這個設定檔用於正向解析:
$TTL 604800
@ IN SOA dns1.com. admin.com. (
19 ; Serial
604820 ; Refresh
86600 ; Retry
2419600 ; Expire
604600 ) ; Negative Cache TTL
; name servers - NS records
IN NS dns1.com.
; name servers - A records
dns1.com. IN A 192.168.56.3
; 192.168.56.0/24 - A records
@ IN NS dns1.com.
host1. IN A 192.168.56.7
host2. IN A 192.168.56.8
我嘗試使用網域連接到兩台主機。第一個打開正確。第二個永遠打不開。
兩者都是pingaple。這是我的機器的第二個主機 ping 結果:C:\Users\e>ping 192.168.56.8
Pinging 192.168.56.8 with 32 bytes of data:
Reply from 192.168.56.8: bytes=32 time<1ms TTL=64
Reply from 192.168.56.8: bytes=32 time<1ms TTL=64
Reply from 192.168.56.8: bytes=32 time<1ms TTL=64
host
如果我透過新增以下項目在 Windows 電腦中使用本機文件,我就能夠解析 host2.com :
192.168.56.8 host2.com
我找不到為什麼我的DNS伺服器無法解析host2
但可以解析host1
?
這是named.conf.local
文件:
zone ".com" {
type master;
file "/etc/bind/forward.host1.com";
};
zone "56.168.192.in-addr.arpa"{
type master;
file "/etc/bind/reverse.host1.com";
};
我不認為檔案名稱forward.host1.com
reverse.host1.com
對解析度有任何影響?他們嗎?
編輯: 若要檢查配置:
/etc/bind$ sudo named-checkzone com forward.host1.com
forward.host1.com:20: ignoring out-of-zone data (host1)
forward.host1.com:21: ignoring out-of-zone data (host2)
zone com/IN: loaded serial 19
OK
誰能告訴我為什麼我無法解析host2?
編輯:在建議答案後,文件已更新為以下內容,但沒有任何希望。我現在無法存取主機 1 和主機 2,儘管它們已啟動並正在運行,我可以透過 IP 存取它們:
$TTL 604800
@ IN SOA dns1.com. admin.com. (
24 ; Serial
604820 ; Refresh
86600 ; Retry
2419600 ; Expire
604600 ) ; Negative Cache TTL
; name servers - NS records
IN NS dns1.com.
; name servers - A records
dns1.com IN A 192.168.56.3
; 192.168.56.0/24 - A records
@ IN NS dns1.com.
host1 IN A 192.168.56.7
host2 IN A 192.168.56.8
答案1
聽起來您好像遇到了一些困難,所以這裡有兩個(希望)適合您的工作範例。請注意,第一個選項(.com
區域)可能會阻止正常.com
域的解析(例如google.com
)。第二個選項(dns1.com
區域)沒有這個缺點。
.com
區域文件範例
前任。 /etc/bind/named.conf.local
; "db.com.tld" is a random name - use whatever you like.
; The same goes for "db.rev.192".
;
; Likewise, you can adjust your "allow-transfer" settings,
; etc. as needed.
zone "com." IN {
type master;
file "/etc/bind/zones/db.com.tld";
allow-transfer { none; };
};
zone "56.168.192.in-addr.arpa" IN {
type master;
file "/etc/bind/zones/db.rev.192";
allow-transfer { none; };
};
前任。 /etc/bind/zones/db.com.tld
; BIND data file for TLD ".com"
;
; This will likely break real ".com" websites (i.e. anything not listed here).
$TTL 3600
@ IN SOA com. admin.com. (
2018040501 ; Serial
604800 ; Refresh period
86400 ; Retry interval
2419200 ; Expire time (28 days... later)
604800 ) ; Negative Cache TTL (1 week)
; Name Servers - NS records
@ IN NS ns1.com. ; This is required
@ IN NS ns2.com. ; You should have two name servers
; Name Servers - A records
ns1 IN A 192.168.56.3 ; This is required
ns2 IN A 192.168.56.3 ; You should have two name servers
; Our domains/sub-domains
dns1 IN A 192.168.56.3 ; dns1.com
host1.dns1 IN A 192.168.56.7 ; host1.dns1.com
host2.dns1 IN A 192.168.56.8 ; host2.dns1.com
請注意,使用這樣的句點是可以的,儘管在這種情況下可以說是多餘的:
;ok.period.com. IN A 192.168.56.3 ; ok.period.com -> FQDN
這是你應該避免的:
;no.period. IN A 192.168.56.3 ; Don't use periods for sub-domains
;no.period.com IN A 192.168.56.3 ; While this works, this is actually accessed as no.period.com.com!
前任。 /etc/bind/zones/db.rev.192
; BIND reverse data file.
; The domain, etc. used should be a listed 'zone' in named.conf.
$TTL 86400
@ IN SOA com. admin.com. (
2018040501 ; Serial
10800 ; Refresh
3600 ; Retry
604800 ; Expire
86400 ) ; Minimum
; In this case, the number just before "PTR" is the last octet
; of the IP address for the device to map (e.g. 192.168.56.[3])
; Name Servers
@ IN NS ns1.com.
@ IN NS ns2.com.
; Reverse PTR Records
3 IN PTR dns1.com.
7 IN PTR host1.dns1.com.
8 IN PTR host2.dns1.com.
請注意,上述設定可能會限制您的電腦存取.com
您建立的網域以外的網域的選項(即它們可能無法存取它們)。如果您希望他們訪問外部.com
網域,您可以嘗試下面更窄的方法。
dns1.com
區域文件範例
前任。 /etc/bind/named.conf.local
; "db.dns1.com" is a random name - use whatever you like.
;
; Likewise, you can adjust your "allow-transfer" settings,
; etc. as needed.
zone "dns1.com" IN {
type master;
file "/etc/bind/zones/db.dns1.com";
allow-transfer { none; };
};
您可以使用named.conf.local
與上面相同的反向區域條目。
前任。 /etc/bind/zones/db.dns1.com
; BIND data for http://dns1.com
$TTL 3600
@ IN SOA ns1.dns1.com. admin.dns1.com. (
2018040501 ; Serial
604820 ; Refresh
86600 ; Retry
2419600 ; Expire
604600 ) ; Negative Cache TTL
; Name Servers - NS records
@ IN NS ns1.dns1.com. ; This is required
@ IN NS ns2.dns1.com. ; You should have two name servers
; Name Servers - A records
ns1 IN A 192.168.56.3 ; This is required
ns2 IN A 192.168.56.3 ; You should have two name servers
; Our domains/sub-domains
dns1.com. IN A 192.168.56.3 ; dns1.com
host1 IN A 192.168.56.7 ; host1.dns1.com
host2 IN A 192.168.56.8 ; host2.dns1.com
前任。 /etc/bind/zones/db.rev.192
; BIND reverse data file.
; The domain, etc. used should be a listed 'zone' in named.conf.
$TTL 86400
@ IN SOA dns1.com. admin.dns1.com. (
2018040501 ; Serial
10800 ; Refresh
3600 ; Retry
604800 ; Expire
86400 ) ; Minimum
; In this case, the number just before "PTR" is the last octet
; of the IP address for the device to map (e.g. 192.168.56.[3])
; Name Servers
@ IN NS ns1.dns1.com.
@ IN NS ns2.dns1.com.
; Reverse PTR Records
3 IN PTR dns1.com.
7 IN PTR host1.dns1.com.
8 IN PTR host2.dns1.com.
答案2
您的區域文件錯誤 - 依照建議位於第 20 行和第 21 行。具體來說,它不應該有“.”。在主機1和主機2之後。
這 。意味著這是絕對的,而不是相對於區域 - 因此它對網域 host1 猶豫不決,並且沒有 host1.com 的條目