4

I'm trying to figure out why nslookup can't find a local host name.

CONFIGURATION I'm trying to setup an authoritative nameserver, working from "DNS and BIND", running bind9, on Debian 5.0, in a chroot "jail". bind seems to start okay, as there are no error messages in syslog. hostname reports "workshop.example.net", hostname -f reports the FQDN as the same. The file /etc/hosts holds a line: "xx.xx.xxx.xx workshop.example.net workshop"

The file /etc/resolv.conf could be a problem; its domain line gets set to an inappropriate value when I reboot. But nslookup still doesn't work after I edit the line to "domain example.net" and restart bind9.

NSLOOKUP OUTPUT nslookup gives the SERVER address of the default name server, but says "can't find workshop: NX domain."

QUERY What could be going wrong here?

Is it possible that the problem is with the registration of the domain's hosts and nameservers? I'm not sure I have the values properly set at the registrar. But I would think that the nslookup should find the address for a local host if I have properly set up bind and the various host and resolv.conf files.

UPDATE Here is the output of dig: Command: dig A @workshop workshop.example.net

Output:

; <<>> DiG 9.5.1-P2 <<>> A @workshop workshop.example.net
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11327
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;workshop.example.net. IN A

;; ANSWER SECTION:
workshop.example.net. 3600 IN A   72.14.190.80

;; AUTHORITY SECTION:
example.net. 3600 IN      NS      workshop.example.net.

;; Query time: 0 msec
;; SERVER: 72.14.190.80#53(72.14.190.80)
;; WHEN: Tue Jul  7 00:25:58 2009
;; MSG SIZE  rcvd: 82

I don't know what I'm looking for here, but the IP address in the ANSWER section is what I would expect.

UPDATE - 2 Okay, this seems to be fixed.

The resolve.conf file now reads as follows:

domain example.net             # This was domain members.linode.net
#search members.linode.com     # Previously, not commented out
nameserver 127.0.0.1           # This line added
nameserver 72.14.179.5
nameserver 72.14.188.5

This reflects three changes from the not-working state: 1) The domain was previously members.linode.com -- I have changed this to my domain's name, which I guess helps by appending 'example.net' to the end of 'workshop'. 2) I've commented out the search line, which I guess was sending the resolver to the members.linode.com domain to look for "workshop". 3) I've added nameserver 127.0.0.1, which I guess means that the resolver looks first at the local nameserver before going to the others.

I don't fully understand the dig output I'm getting for 'workshop', but I'm going to look at dig before I ask any questions about it.

Many thanks to all who took the trouble to look at this and guess at the problem.

5 Answers 5

4

QUERY What could be going wrong here?

A couple of things are conspiring against you. :-(

The file /etc/resolv.conf could be a problem; its domain line gets set to an inappropriate value when I reboot.

How is your /etc/resolv.conf being created/populated?

My guess is that your IP address is being assigned by a DHCP server. As part of the IP address assignment, your DHCP client is rewriting /etc/resolv.conf with the domain and nameserver assigned by the DHCP server. Hence, the "inappropriate" value after you reboot.

NSLOOKUP OUTPUT nslookup gives the SERVER address of the default name server, but says "can't find workshop: NX domain."

This is because your default DNS server is not your local DNS server -- it is one of the DNS servers assigned to you by the DHCP server. This "other" DNS server does not know about your domain.

But nslookup still doesn't work after I edit the line to "domain example.net" and restart bind9.

That's because you need to add your local DNS server to the list of nameservers in /etc/resolv.conf. Immediately before any other nameserver entry, add ...

nameserver 127.0.0.1

Now, when you use nslookup, your local DNS server should be your default DNS server. nslookup should now be able to resolve "workshop".

UPDATE Here is the output of dig: Command: dig A @workshop workshop.example.net

This confirms that you have your domain correctly configured on your local bind DNS server.

As you've already experienced, your changes to /etc/resolv.conf will be overwritten the next time you reboot. You have two options:

  • Reconfigure your machine to use a static IP. /etc/resolv.conf won't be overwritten anymore, so your changes will persist after a reboot.

  • Reconfigure your DHCP client so that it does not overwrite /etc/resolv.conf. This thread should point you in the right direction.

0
2

bind won't use your /etc/hosts file. And nslookup will query sources as listed in "/etc/nsswitch.conf".

The domain line from /etc/resolv.conf is used only to complete hostnames without domain, ie: "nslookup workshop".

For further testing I'd suggest using dig:

dig A @server workshop.example.net

This will query the dns server "server" for the A record of "workshop.example.net".

1
  • From his description, it doesn't sound like nslookup goes through nss, since the domain is in /etc/hosts, so should be found by it, if it goes though nss, rather than straight to DNS. That said, I'd agree with using dig rather than nslookup.
    – Cian
    Jul 6, 2009 at 22:48
1

Is workshop.example.com in the zonefile for example.com? bind does not read your /etc/hosts, only it's zone files.

1
  • They weren't initially, but the problem persisted after I fixed this.
    – chernevik
    Jul 7, 2009 at 13:17
1

You might want to set nslookup to use a debug mode. Since you have dig, I'm presuming a linux-like server here.

> set debug
> www.yourdomain.net
Server:          [your primary dns]
Address:         [your primary dns]

--------------
[whole bunch of data]

The output just might give you more information. "set debug2" works on some platforms to give more information (for instance, on WinXP it'll tell you the TTL value for the returned results, handy!)

1

NSLOOKUP OUTPUT nslookup gives the SERVER address of the default name server, but says "can't find workshop: NX domain."

Is the default server that nslookup uses different from the one you are setting up? In the dig output you cited, you specifically queried the server "workshop" and got the correct answer. A nslookup command to accomplish the same would be nslookup workshop.example.net server.

If that works, then you just need to make your computer use your server. /etc/resolv.conf woul d be the first place to do that.

1
  • This was one problem. I'd tried putting in "nameserver 0.0.0.0", but this didn't work. 127.0.0.1 did, though I also had to change the domain line and comment out a "search" line.
    – chernevik
    Jul 7, 2009 at 13:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .