LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   DNS short name problem. FQDN worked (https://www.linuxquestions.org/questions/linux-server-73/dns-short-name-problem-fqdn-worked-4175510642/)

akeka 07-09-2014 09:56 PM

DNS short name problem. FQDN worked
 
Dear Guru's

I've setup local DNS on my lab

The problem is, I need the short name to be also working . Right now, I can use FQDN without problem

Here's my conf

named.conf
Code:

options {
        directory "/var/named";
        dump-file "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        forwarders { 8.8.8.8; 4.4.4.4; };
        notify no;
};

# This is where you put in the link to the zone you
# want to serve

zone "labs.com" in {
        type master;
        file "/var/lib/named/labs.com.zone";
        allow-update { none; };
};

include "/etc/rndc.key";

zone file labs.com.zone
Code:

$TTL 86400
@  IN  SOA    ns1.labs.com. root.labs.com. (
        2013042201  ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400      ;Minimum TTL
)
; Specify our two nameservers
                IN      NS              ns1.labs.com.
; Resolve nameserver hostnames to IP, replace with your two droplet IP addresses.
ns1            IN      A              10.0.0.15

; Define hostname -> IP pairs which you wish to resolve

labs-host1            IN      A              10.0.0.12
labs-host2            IN      A              10.0.0.14

Thanks and regards,

bathory 07-10-2014 12:01 AM

Hi,

Add in /etc/resolv.conf
Code:

domain labs.com
Regards

akeka 07-10-2014 12:25 AM

Quote:

Originally Posted by bathory (Post 5201510)
Hi,

Add in /etc/resolv.conf
Code:

domain labs.com
Regards

Hi, thank you for your reply

It still doesn't worked, thanks

bathory 07-10-2014 12:46 AM

Quote:

Originally Posted by akeka (Post 5201520)
Hi, thank you for your reply

It still doesn't worked, thanks

Can you give an example of what is not working?

akeka 07-10-2014 12:55 AM

Quote:

Originally Posted by bathory (Post 5201530)
Can you give an example of what is not working?

Here's the result if I use FQDN

Code:

[root@client1 named]# dig labs-host1.labs.com

; <<>> DiG 9.2.4 <<>> labs-host1.labs.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46470
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;labs-host1.labs.com.                IN      A

;; ANSWER SECTION:
labs-host1.labs.com. 86400  IN      A      10.0.0.12

;; AUTHORITY SECTION:
labs.com.              86400  IN      NS      ns1.labs.com.

;; ADDITIONAL SECTION:
ns1.labs.com.          86400  IN      A      10.0.0.15

;; Query time: 0 msec
;; SERVER: 10.0.0.15#53(10.0.0.15)
;; WHEN: Thu Jul 10 12:49:45 2014
;; MSG SIZE  rcvd: 90

Here's the result if I use short name

Code:

[root@client1 named]# dig labs-host1

; <<>> DiG 9.2.4 <<>> labs-host1
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 23722
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;labs-host1.                  IN      A

;; AUTHORITY SECTION:
.                      5498    IN      SOA    a.root-servers.net. nstld.verisign-grs.com. 2014070901 1800 900 604800 86400

;; Query time: 0 msec
;; SERVER: 10.0.0.15#53(10.0.0.15)
;; WHEN: Thu Jul 10 12:52:57 2014
;; MSG SIZE  rcvd: 105

Here's my /etc/resolv.conf

Code:

#search labs.com
domain labs.com
nameserver 10.0.0.15


bathory 07-10-2014 01:41 AM

You could use other network tools (like nslookup, ping etc) to do your tests.
Anyways for dig you need to add the "+search" option, e.g:
Code:

dig labs-host1 +search

YankeePride13 07-10-2014 08:23 AM

Why do you have search commented out in /etc/resolv.conf? If you uncomment then, it should work as you want it to.

akeka 07-10-2014 09:25 PM

Quote:

Originally Posted by bathory (Post 5201550)
You could use other network tools (like nslookup, ping etc) to do your tests.
Anyways for dig you need to add the "+search" option, e.g:
Code:

dig labs-host1 +search

Hmmm, I don't know if I've to add +search at the dig

When I use ping, it worked even if I use short name

So I guess, the configuration are working since the first time :)

Still wondering though, can I just type dig <short name> ? :)

Thanks and regards

bathory 07-11-2014 12:17 AM

Quote:

Hmmm, I don't know if I've to add +search at the dig
You need it if you want dig to use /etc/resolv.conf to resolve the "short name". From the dig manpage:
Quote:

+[no]search
Use [do not use] the search list defined by the searchlist or domain directive in resolv.conf (if any).
The search list is not used by default.


All times are GMT -5. The time now is 03:42 PM.