CentOS7 无法解析短主机名的 nslookup

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

我知道我的配置中有一些缺失/错误,但我无法弄清楚是什么。

答案1

resolv.conf如果 resolv.conf 不是静态的,则问题出在您的/DHCP 配置中。

您必须添加到域 eai.comsearch的指令resolv.conf

当您尝试 DNS 名称查找时,解析器库如果不成功,则会依次尝试解析在搜索指令中添加域的名称,直到找到可解析的名称,或者直到耗尽搜索指令中的域列表。

相关内容