1

I tried setting up a DNS Lookup on CentOS 7 (in a Virtual Box VM), which works for FQDN on the same virtual machine as the DNS. However when I try to resolve the short hostname, it fails.

I have seen this working on some servers and wanted to learn how to set it up myself. Appreciate any help on this.

Below are the configurations in place:

File - /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";

File - /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

File - /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

File - /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

File - /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.

Command Output

Hostname

[root@eai16 etc]# hostname -f
eai16.eai.com
[root@eai16 etc]# hostname -s
eai16

NS Lookup on FQDN

[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

Dig on 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

Host on 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

Now all the commands (nslookup, dig and host) fail on the short hostname.

[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

I know there is something missing/wrong in my configuration, but am not able to figure out what.

0

The problem is in your resolv.conf/DHCP configuration if resolv.conf is not static.

You have got to add to the search directive of resolv.conf the domain eai.com

When you try a DNS name lookup, the resolver libraries, if unsuccessful, try in turns to resolve the name adding the domains in the search directive until they find a resolvable name, or until they exhaust the domain list in the search directive.

  • 1
    Thanks Rui F Ribeiro, adding the search configuration in resolve.conf fixed the issue. Greatly appreciate your input on this. – WrijuB Jul 6 '17 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.