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

7,266

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
Share:
7,266

Related videos on Youtube

einpoklum
Author by

einpoklum

Made my way from the Olympus of Complexity Theory, Probabilistic Combinatorics and Property Testing to the down-to-earth domain of Heterogeneous and GPU Computing, and now I'm hoping to bring the gospel of GPU and massive-regularized parallelism to DBMS architectures. I've post-doc'ed at the DB architecture group in CWI Amsterdam to do (some of) that. I subscribe to most of Michael Richter's critique of StackOverflow; you might want to take the time to read it. If you listen closely you can hear me muttering "Why am I not socratic again already?"

Updated on September 18, 2022

Comments

  • einpoklum
    einpoklum over 1 year

    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:

    • user9517
      user9517 over 10 years
      So far all you (appear) to know is that dnsmasq is listening and responding on the server's 127.0.0.1 intrface. Is dnsmasq listening on 192.168.0.1 (dig @192.168.0.1 ... | netstat ...)? Can the remote machines contact 192.168.0.1 at all (ping ssh etc )?
    • einpoklum
      einpoklum over 10 years
      @Iain: Yes it is, and yes they can. Updated question accordingly.
    • Håkan Lindqvist
      Håkan Lindqvist over 9 years
      Do you get any more hints as to what is happening if you do set debug in nslookup before the query?
    • einpoklum
      einpoklum over 9 years
      @HåkanLindqvist: This was over a year ago, I'm no longer experiencing the problem.
  • Zeeshan
    Zeeshan over 10 years
    Yes, you are correct. I was trying to drill it down step by step. As all the configuration seems correct. I guess the problem is here--> hosts: files mdns4_mininal [NOTFOUND=return] dns mdns4 Check the following link You need to install apt-get install winbind
  • Zeeshan
    Zeeshan over 10 years
    okay deleted you can check the link in my last comment, if it works for you
  • einpoklum
    einpoklum over 10 years
    Well, it turns out pinging actually works. I was running ping with a wrong setup before. The conundrum is still basically the same though.