Why can host and nslookup resolve a name but dig cannot?

2,027

Solution 1

It's the default behaviour of dig not to use the search-option.

From the manual page:

   +[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.

Edit: Just add +search to make it work, like dig +search myhost.

Solution 2

In my case, it is a bug in Microsoft DNS Server, where it returns FORMERR response (request format error) for requests with EDNS Cookie option set. Newer versions of dig (9.11 and up) use dns-cookies by default. This can be prevented by +nocookie or +noedns flag to dig:

$ dig +nocookie DOMAIN @SERVER

Source: https://kevinlocke.name/bits/2017/01/20/formerr-from-microsoft-dns-server-for-dig/

Solution 3

I was having the same problem. After inspecting packets sent from both nslookup and dig with wireshark, I found the problem.

dig was setting the authentic data bit in the query. According to the man page, "This requests the server to return whether all of the answer and authority sections have all been validated as secure according to the security policy of the server." By running dig with +noadflag, it returned the same results as nslookup.

Solution 4

You can use a .digrc file in your home directory with the line

+search

to chance the default behaviour

Share:
2,027

Related videos on Youtube

Raj
Author by

Raj

Updated on September 18, 2022

Comments

  • Raj
    Raj over 1 year

    When I use a BFS algorithm on a graph, I try to obtain the maximum depth of the graph.

    But I don't know where to put my incrementation in this algorithm :

    FUNCTION BFS(G,s) 
        BEGIN 
            FOR any vertex v of G 
            DO Mark[v] ← False 
            END FOR Mark[s] ← True 
        F ← Empty Queue 
        enqueue(s,F) 
            WHILE F is not empty 
            DO  v ← dequeue(F) 
                FOR any vertex w neighbor of v 
                DO
                    IF Mark[w] = False THEN 
                    Mark[w] ← True; 
                    enqueue(w,F) 
                    END IF  
                FOR END 
            WHILE END
    

    I tried to put an incrementation of a number after the END FOR but it gives an number superior than the real max depth of the graph.

    Please can anyone help me.

    Thank You.

    • gue
      gue about 7 years
      What kind of graph is this and how do you define this maximum depth?
    • Raj
      Raj about 7 years
      Hello, I posted an answer just below.
  • musashiXXX
    musashiXXX over 11 years
    Am I the only one who sees that as being a little counter-intuitive? :-) Anyway, thanks a lot!
  • Alexander Janssen
    Alexander Janssen over 11 years
    @musashiXXX Well, it depends :-) Most people use dig for debugging DNS and in this case it's quite a good idea to disable everything which might mess up the answers from DNS. I think it's a pretty good idea; most people use host and nslookup after all. :-)
  • Raj
    Raj about 7 years
    Thank you very much for your answer. I also tried one different solution very similar to yours and it works
  • Abdulhakeem
    Abdulhakeem about 7 years
    That is not what you have asked. This is the mere BFS algorithm which finds the distance of all vertices of graph G from a source vertex. DIST is an array of values, you need to do one extra O(V) (V is the number of vertices in graph G) to find the max value from DIST which will be the depth of the tree. So if you want to find the depth of tree in just O(V+E), I would say the other approach is more efficient.
  • Raj
    Raj almost 7 years
    Hello, Thank you for your comment, i just corrected my answer, i posted the wrong one. Now its correct normally.
  • Slava Bacherikov
    Slava Bacherikov over 6 years
    Had same issue, but different result was caused by edns extension. When I made query with +noends dig returned same result as host.