I am reading about how DNS works in general. From the wiki entry of TTL, I understand TTL (Time to Live) occur in the Domain Name System (DNS), where they are set by an authoritative name server for a particular resource record. When a caching (recursive) nameserver queries the authoritative nameserver for a resource record, it will cache that record for the time (in seconds) specified by the TTL.

Now, I needed to use the Linux CLI tools (dig) to figure out what is the actual TTL set in the authoritative name server and so used my command as below.

dig +trace +nocmd +noall +answer +ttlid a www.stackoverflow.com

#I have omitted the root name server output for better readability. 

www.stackoverflow.com.  300 IN  CNAME   stackoverflow.com.
stackoverflow.com.  300 IN  A
;; Received 80 bytes from in 9 ms

As I could see from the A record of stackoverflow.com., the TTL value in the authoritative name server is 300.

So, does this mean, if I search for stackoverflow.com after 300 seconds or 5 minutes, the IP address of stackoverflow.com would be resolved all the way from the .com domain?


No; not all the way from the .com domain (actually I think you meant from the root domain?).

The NS records for stackoverflow.com have a TTL of 172800, so those are cached a lot longer than the 300 seconds of the www.stackoverflow.com CNAME record and the stackoverflow.com A record. So after those CNAME and A records have expired, the NS records will probably still be cached and hence those nameservers can be questioned about www.stackoverflow.com (and then stackoverflow.com).

BTW I wouldn't have given both www.stackoverflow.com and stackoverflow.com a TTL of just 300, that means twice as many DNS requests without any immediately evident advantage IMHO.

  • 1
    Thanks. So, how can I find out the value of 172800 using the dig command? – Ramesh Dec 9 '14 at 17:15
  • If you leave out the +noall +answer from your dig command you also get the intermediate results and there you'll see the TTL for all entries found, including the nameservers. – wurtel Dec 10 '14 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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