LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Bind on local network: can't do short hostname and reverse lookups (http://www.linuxquestions.org/questions/slackware-14/bind-on-local-network-cant-do-short-hostname-and-reverse-lookups-4175440551/)

kikinovak 12-08-2012 04:22 AM

Bind on local network: can't do short hostname and reverse lookups
 
Hi,

On my local network I have a Slackware 14.0 server running with Bind configured as a primary master for the bogus domain "microlinux.montpezat". Here's my configuration.


Code:

// /etc/named.conf
options {
        directory "/var/named";
        query-source address * port 53;
  forwarders {
    195.5.209.150;
    194.79.128.150;
  };
};

zone "." IN {
        type hint;
        file "named.root";
};

zone "localhost" IN {
        type master;
        file "localhost.zone";
        allow-update { none; };
};

zone "0.0.127.in-addr.arpa" IN {
        type master;
        file "named.local";
        allow-update { none; };
};

zone "microlinux.montpezat" {
  type master;
  file "/var/named/zone.microlinux.montpezat";
};

zone "2.168.192.in-addr.arpa" {
  type master;
  file "/var/named/revp.192.168.2";
};

The zone file for "microlinux.montpezat":

Code:

; zone.microlinux.montpezat
$TTL 86400
$ORIGIN microlinux.montpezat.
@ IN SOA nestor.microlinux.montpezat. hostmaster.microlinux.montpezat. (
    2012080300 ; serial
    3H        ; refresh
    15M        ; retry
    1W        ; expiry
    1D )      ; minimum
  IN NS  nestor.microlinux.montpezat.
nestor        IN A 192.168.2.1
alphamule      IN A 192.168.2.2
bernadette    IN A 192.168.2.3
raymonde      IN A 192.168.2.4
betadine      IN A  192.168.2.5
buzz          IN A  192.168.2.6
bebette        IN A  192.168.2.7
jukebox        IN A  192.168.2.8

mirror.nestor            IN A 192.168.2.1
dan-services.nestor      IN A 192.168.2.1
dolibarr.nestor          IN A 192.168.2.1
kikinovak.nestor        IN A 192.168.2.1
microlinux.nestor        IN A 192.168.2.1
oldmicrolinux.nestor    IN A 192.168.2.1
oldscholae.nestor        IN A 192.168.2.1
osteo-montpellier.nestor IN A 192.168.2.1
osteo-sommieres.nestor  IN A 192.168.2.1
phpinfo.nestor          IN A 192.168.2.1
radionovak.nestor        IN A 192.168.2.1
scholae.nestor          IN A 192.168.2.1
villa-figaret.nestor    IN A 192.168.2.1
xhtml.nestor            IN A 192.168.2.1

And the reverse zone file:

Code:

; revp.192.168.2
$TTL 86400
$ORIGIN 2.168.192.IN_ADDR.ARPA.
@ IN SOA nestor.microlinux.montpezat. hostmaster.microlinux.montpezat. (
    2012080300 ; serial
    3H        ; refresh
    15M        ; retry
    1W        ; expiry
    1D )      ; minimum
    IN  NS  nestor.microlinux.montpezat.
1  IN  PTR nestor.microlinux.montpezat.
2  IN  PTR alphamule.microlinux.montpezat.
3  IN  PTR bernadette.microlinux.montpezat.
4  IN  PTR raymonde.microlinux.montpezat.
5  IN  PTR betadine.microlinux.montpezat.
6  IN  PTR buzz.microlinux.montpezat.
7  IN  PTR bebette.microlinux.montpezat.
8  IN  PTR jukebox.microlinux.montpezat.

Now this configuration works OK, in that hosts can ping each other by hostnames OK, but two things are bugging me here.

When using dig on a local hostname, I can't seem to use the short hostname without the FQDN part to get an answer. I don't know if this behavior is normal.

This works:
Code:

[kikinovak@alphamule:~] $ dig raymonde.microlinux.montpezat +short
192.168.2.4

This doesn't work:

Code:

[kikinovak@alphamule:~] $ dig raymonde +short
The second thing that's bugging me is that reverse lookups don't work at all. I expect the following command to return the hostname (raymonde), but there's nothing:

Code:

[kikinovak@alphamule:~] $ dig -x 192.168.2.4

; <<>> DiG 9.9.1-P4 <<>> -x 192.168.2.4
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 31737
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;4.2.168.192.in-addr.arpa.        IN        PTR

;; Query time: 2 msec
;; SERVER: 192.168.2.1#53(192.168.2.1)
;; WHEN: Sat Dec  8 11:18:34 2012
;; MSG SIZE  rcvd: 53

Any idea what's wrong here?

Cheers,

Niki

kikinovak 12-08-2012 06:21 AM

After much more googling and debugging and experimenting, I got a little further, and it looks like it's almost perfectly working. A few little questions remain though. But first things first.

The server is running DHCP and DNS, so here's what /etc/dhcpd.conf looks like (I shortened the listings down to one server and three clients:

Code:

# /etc/dhcpd.conf
authoritative;
default-lease-time 86400;
max-lease-time 86400;
option broadcast-address 192.168.2.255;
option subnet-mask 255.255.255.0;
option routers 192.168.2.254;
option domain-name-servers 192.168.2.1;
option domain-name "microlinux.montpezat";
option domain-search "microlinux.montpezat";

subnet 192.168.2.0 netmask 255.255.255.0 {
        range 192.168.2.100 192.168.2.200;
}

host alphamule {
        hardware ethernet 00:1D:92:B2:F3:9E;
        fixed-address 192.168.2.2;
        option host-name "alphamule";
}

host bernadette {
        hardware ethernet 00:1D:09:15:4A:D8;
        fixed-address 192.168.2.3;
        option host-name "bernadette";
}

host raymonde {
        hardware ethernet 00:1E:C9:43:A7:BF;
        fixed-address 192.168.2.4;
        option host-name "raymonde";
}

I added the domain-search option, so now a client's /etc/resolv.conf looks like this:

Code:

# Generated by dhcpcd from eth0
# /etc/resolv.conf.head can replace this line
domain microlinux.montpezat
search microlinux.montpezat
nameserver 192.168.2.1
# /etc/resolv.conf.tail can replace this line

No changes were made to /etc/named.conf.

The zone file for the "microlinux.montpezat" zone looks like this:

Code:

; zone.microlinux.montpezat
$TTL 86400
$ORIGIN microlinux.montpezat.
@ IN SOA nestor.microlinux.montpezat. hostmaster.microlinux.montpezat. (
    2012120805 ; serial
    3H        ; refresh
    15M        ; retry
    1W        ; expiry
    1D )      ; minimum
                        IN NS nestor.microlinux.montpezat.
nestor                  IN A 192.168.2.1
alphamule                IN A 192.168.2.2
bernadette              IN A 192.168.2.3
raymonde                IN A 192.168.2.4

And here's the reverse zone file:

Code:

; revp.192.168.2
$ORIGIN 2.168.192.in-addr.arpa.
$TTL 86400
@ IN SOA nestor.microlinux.montpezat. hostmaster.microlinux.montpezat. (
    2012120805 ; serial
    3H        ; refresh
    15M        ; retry
    1W        ; expiry
    1D )      ; minimum
    IN NS  nestor.microlinux.montpezat.
1  IN PTR nestor.microlinux.montpezat.
2  IN PTR alphamule.microlinux.montpezat.
3  IN PTR bernadette.microlinux.montpezat.
4  IN PTR raymonde.microlinux.montpezat.

Now I can do the following from any machine on the network.

Query a hosts' IP address using nslookup:

Code:

[kikinovak@alphamule:~] $ nslookup raymonde
Server:                192.168.2.1
Address:        192.168.2.1#53

Name:        raymonde.microlinux.montpezat
Address: 192.168.2.4

Query an IP address to know the hostname using nslookup:
Code:

[kikinovak@alphamule:~] $ nslookup 192.168.2.4
Server:                192.168.2.1
Address:        192.168.2.1#53

4.2.168.192.in-addr.arpa        name = raymonde.microlinux.montpezat.

Query an IP address using dig, but only with the FQDN:

Code:

[kikinovak@alphamule:~] $ dig raymonde.microlinux.montpezat +short
192.168.2.4

Here's what still doesn't work, and I don't know why:

Code:

[kikinovak@alphamule:~] $ dig raymonde

; <<>> DiG 9.9.1-P4 <<>> raymonde
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 27327
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;raymonde.                        IN        A

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

;; Query time: 3 msec
;; SERVER: 192.168.2.1#53(192.168.2.1)
;; WHEN: Sat Dec  8 13:19:06 2012
;; MSG SIZE  rcvd: 112

Maybe this behavior is normal, after all.

Any suggestions? Anyone spotted some misconfiguration somewhere?

wildwizard 12-08-2012 06:46 AM

Normal operation of dig.

A hint, the question section shows the lookup of :-

raymonde.

note the trailing dot, this dot means that there is nothing else to the right of the name been searched.

dig is different to the old nslookup tool in that it designed specifically as a tool to query name servers therefore your domain name search string is not used as it is assumed that you have given the entire search string on the command line.

kikinovak 12-08-2012 06:54 AM

Thanks very much for the clarification!


All times are GMT -5. The time now is 02:37 PM.