Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm wondering if there is a way to query a DNS server and bypass caching (with dig). Often I change a zone on the DNS server and I want to check if it resolves correctly from my workstation. But since the server caches resolved requests, I often get the old ones. Restarting or -loading the server is not really something nice.

share|improve this question

2 Answers 2

up vote 21 down vote accepted

You can use the @ syntax to look up the domain from a particular server. If the DNS server is authoritative for that domain, the response will not be a cached result.

dig @ns1.example.com example.com

You can find the authoritative servers by asking for the NS records for a domain:

dig example.com NS
share|improve this answer
    
Oh okay. Yeah I was familiar with the @ syntax, but haven't had the idea to query the authoritative server instead. Thanks! –  Daniel Mar 21 '12 at 17:22
2  
Side note: in cases where you're trying to see what responses a caching server would get, +norecurse is recommended. +recurse is on by default will occasionally change the way a DNS server interprets your question entirely. –  Andrew B Mar 1 '13 at 4:37
1  
What if you're waiting for the authoritative servers to change? –  Kasper Souren Aug 5 at 12:12
    
@KasperSouren Are you talking about the NS records at the authoritative servers or the glue records at the parent? You can find the parent with +trace but beware of caching. Andrew B wrote up a good explanation of how caching can trick you when waiting for nameservers to change. –  Ladadadada Aug 7 at 6:46

I'd do it by adding the +norecurse or +trace option. These disable the use of recursive DNS which is what allows non-authoritative caches, and forces going to the authoritative servers.

dig example.com +norecurse

or

dig example.com +trace

The added benefit of using +trace is that you get to see all of the separate requests made along the path.

share|improve this answer
    
Using +norecurse just tells the nameserver to return whatever information it has (including cached info, if any), so that isn't correct. +trace will work because it will follow the recursion chain all the way to an authoritative server. –  Raman Dec 5 at 21:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.