Dig succeeds, nslookup fails (with dnsmasq as the server)

digdns-lookupdnsmasqdomain-name-systemnslookup

I installed dnsmasq on a machine of mine (It's a Kubuntu 12.04 LTS), backed only by /etc/hosts (no connection to the Internet until later). Now, if I dig mymachine, I get 192.168.0.1, but if I try to nslookup mymachine, I get:

>> connection timed out; no servers could be reached

Tried also nslookup mymachine.mynicedomain.org – didn't work either. pinging (Edit:) succeeds. This happens both on the server machine itself and on other machines on the network.

How can I get the DNS lookups to work? What problem is preventing nslookup from succeeding?

Additional Information

In the server's /etc/hosts:

192.168.0.1   mymachine

In the server's nsswitch.conf:

hosts: files mdns4_mininal [NOTFOUND=return] dns mdns4

(admittedly, this is a bit weird; but I also tried:

hosts: files dns

instead, with the same effect)

In resolv.conf (which is generated by dnsmasq):

nameserver 127.0.0.1
search mynicedomain.org

In the server's /etc/hosts.allow:

domain: ALL    

In the other machines' /etc/resolv.conf (this is set by the DHCP client):

nameserver 192.168.0.1
search mynicedomain.org

Relevant netstat output on the server:

Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN
tcp        0      0 192.168.0.1:53          0.0.0.0:*               LISTEN

Finally, here's the ipconfig output from one of the client machines on the network (running Windows 7):

Connection-specific DNS Suffix  . : mynicedomain.org
Description . . . . . . . . . . . : Intel(R) 82579LM Gigabit Network Connection
Physical Address. . . . . . . . . : 12-34-56-78-9A-BC
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 192.168.0.50(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Sunday, October 20th 2013 16:20:25
Lease Expires . . . . . . . . . . : Sunday, October 20th 2013 18:20:24
Default Gateway . . . . . . . . . : 192.168.0.1
DHCP Server . . . . . . . . . . . : 192.168.0.1
DNS Servers . . . . . . . . . . . : 192.168.0.1
NetBIOS over Tcpip. . . . . . . . : Enabled

Notes:

Best Answer

Have you configured your /etc/resolv.conf? If not, it should be as follows:

search mynicedomain.org
nameserver 192.168.0.1 

When you use BIND or other DNS Servers, you should change /etc/nsswitch.conf file accordingly.

The following options are available:

  • dns: Use the Domain Name System (DNS) service to resolve the address. This makes sense only for host address resolution, not network address resolution. This mechanism uses the /etc/resolv.conf file.
  • files: Search a local file for the host or network name and its corresponding address. This option uses the traditional /etc/hosts and /etc/network files.

Your /etc/nsswitch.conf file should contain a like this, to enable DNS lookups.

hosts:       dns files
Related Topic