How to see the TTL value of a DNS record
How to see the TTL value of a DNS record?
Run the dig command and have it show the TTL value with the help of the +ttlunits option.
dig +noall +answer +ttlunits RECORD HOSTThe TTL value defines how long a DNS record normally should be cached. Although not all resolvers will adhere to it, many do. In that case it may be useful to learn how much time is still left on the TTL.
Using dig to query the TTL
With the dig command we query the current TTL value. That is, the value returned by your DNS resolver. When the value reaches zero, a new request should be done to the upstream servers, often the authoritative server.
dig +noall +answer +ttlunits A linux-audit.com
So what does this command do?
Dig option | Action performed |
---|---|
+noall | Filter results, don’t show all details of the query response |
+answer | Include the actual answer in the output |
+ttlunits | Show a human friendly output, instead of seconds |
For readability we normally list all options in alphabetical order. For this command it is important that +answer comes after +noall, otherwise the answer will be filtered out.