Centos
CentOS7 無法解析 nslookup 的短主機名
我嘗試在 CentOS 7(在 Virtual Box VM 中)上設置 DNS 查找,它適用於與 DNS 相同的虛擬機上的 FQDN。但是,當我嘗試解析短主機名時,它失敗了。
我已經看到這在一些伺服器上工作,並想學習如何自己設置它。感謝您對此的任何幫助。
以下是現有的配置:
文件 - /etc/named.conf
// // named.conf // options { listen-on port 53 { 127.0.0.1; 192.168.56.101; }; listen-on-v6 port 53 { ::1; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; allow-query { localhost; 192.168.0.0/24; }; allow-transfer { localhost; 192.168.56.101; }; recursion yes; dnssec-enable yes; dnssec-validation yes; dnssec-lookaside auto; /* Path to ISC DLV key */ bindkeys-file "/etc/named.iscdlv.key"; managed-keys-directory "/var/named/dynamic"; pid-file "/run/named/named.pid"; session-keyfile "/run/named/session.key"; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; zone "." IN { type hint; file "named.ca"; }; zone "eai.com" IN { type master; file "forward.linuxzadmin"; allow-update { none; }; }; zone "0.168.192.in-addr.arpa" IN { type master; file "reverse.linuxzadmin"; allow-update { none; }; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key";
文件 - /etc/resolv.conf
# Generated by NetworkManager # nameserver 169.144.126.136 # nameserver 146.11.115.200 # nameserver 153.88.112.200 # NOTE: the libc resolver may not support more than 3 nameservers. # The nameservers listed below may not be recognized. # nameserver 147.128.170.138 # nameserver 127.0.0.1 nameserver 192.168.56.101
文件 - /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.56.101 eai16.eai.com eai16 eai16-oam
文件 - /var/named/forward.linuxzadmin
$TTL 86400 @ IN SOA masterdns.eai.com. root.eai.com. ( 2014051001 ; serial 3600 ; refresh 1800 ; retry 604800 ; expire 86400 ; minimum ) @ IN NS masterdns.eai.com. @ IN A 192.168.56.101 masterdns IN A 192.168.56.101 node1 IN A 192.168.56.101 eai16 IN A 192.168.56.101
文件 - /var/named/reverse.linuxzadmin
$TTL 86400 @ IN SOA masterdns.eai.com. root.eai.com. ( 2014051001 ; serial 3600 ; refresh 1800 ; retry 604800 ; expire 86400 ; minimum ) @ IN NS masterdns.eai.com. @ IN PTR eai.com. masterdns IN A 192.168.56.101 node1 IN A 192.168.56.101 eai16 IN A 192.168.56.101 101 IN PTR masterdns.eai.com. 101 IN PTR node1.eai.com. 101 IN PTR eai16.eai.com. 101 IN PTR eai16.
命令輸出
主機名
[root@eai16 etc]# hostname -f eai16.eai.com [root@eai16 etc]# hostname -s eai16
FQDN 上的 NS 查找
[root@eai16 etc]# nslookup eai16.eai.com Server: 192.168.56.101 Address: 192.168.56.101#53 Name: eai16.eai.com Address: 192.168.56.101
探勘 FQDN
[root@eai16 etc]# dig eai16.eai.com ; <<>> DiG 9.9.4-RedHat-9.9.4-38.el7_3.3 <<>> eai16.eai.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62927 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;eai16.eai.com. IN A ;; ANSWER SECTION: eai16.eai.com. 86400 IN A 192.168.56.101 ;; AUTHORITY SECTION: eai.com. 86400 IN NS masterdns.eai.com. ;; ADDITIONAL SECTION: masterdns.eai.com. 86400 IN A 192.168.56.101 ;; Query time: 0 msec ;; SERVER: 192.168.56.101#53(192.168.56.101) ;; WHEN: Wed Jun 28 21:13:38 IST 2017 ;; MSG SIZE rcvd: 98
FQDN 上的主機
[root@eai16 etc]# host eai16.eai.com eai16.eai.com has address 192.168.56.101 [root@eai16 etc]# host `hostname` eai16.eai.com has address 192.168.56.101
現在所有命令(nslookup、dig 和 host)在短主機名上都失敗了。
[root@eai16 etc]# host eai16 Host eai16 not found: 2(SERVFAIL) [root@eai16 etc]# host eai16 ;; connection timed out; no servers could be reached [root@eai16 etc]# nslookup eai16 Server: 192.168.56.101 Address: 192.168.56.101#53 ** server can't find eai16: SERVFAIL [root@eai16 etc]# dig eai16 ; <<>> DiG 9.9.4-RedHat-9.9.4-38.el7_3.3 <<>> eai16 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 23006 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;eai16. IN A ;; Query time: 0 msec ;; SERVER: 192.168.56.101#53(192.168.56.101) ;; WHEN: Wed Jun 28 21:25:18 IST 2017 ;; MSG SIZE rcvd: 34
我知道我的配置中缺少/錯誤,但無法弄清楚是什麼。
resolv.conf
如果 resolv.conf 不是靜態的,則問題出在您的/DHCP 配置中。您必須添加到域 eai.com的
search
指令中resolv.conf
當您嘗試 DNS 名稱查找時,如果不成功,解析器庫會依次嘗試在搜尋指令中添加域來解析名稱,直到它們找到可解析的名稱,或者直到它們耗盡搜尋指令中的域列表。