How to Find a DNS Record's TTL Value

With the 'dig' (domain information groper) command, it is possible to look up the TTL (time-to-live) value of a DNS record. For example, you may want to lookup the 'A' record for chrisburge.net:

$ dig a chrisburge.net

See below for the results:

; <<>> DiG 9.8.5-P1 <<>> a chrisburge.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26206
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;chrisburge.net.   IN A

;; ANSWER SECTION:
chrisburge.net.  542 IN A 198.58.107.11

;; Query time: 896 msec
;; SERVER: 172.16.10.1#53(172.16.10.1)
;; WHEN: Thu Nov 20 19:51:51 CST 2014
;; MSG SIZE  rcvd: 48

In the 'ANSWER SECTION', the value after the domain, '542', represents the amount of time, in seconds, until the record expires from the DNS server's cache. It doesn't tell us the TTL value on the record, however. To find that, we'll need to query one of the domain's authoritative name servers. To find a listing of authoritative name servers, we'll execute a 'whois' command on the domain:

$ whois chrisburge.net

See below for the results:

Whois Server Version 2.0

Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.

   Domain Name: CHRISBURGE.NET
   Registrar: TUCOWS DOMAINS INC.
   Whois Server: whois.tucows.com
   Referral URL: http://domainhelp.opensrs.net
   Name Server: FREEDNS1.REGISTRAR-SERVERS.COM
   Name Server: FREEDNS2.REGISTRAR-SERVERS.COM
   Name Server: FREEDNS3.REGISTRAR-SERVERS.COM
   Name Server: FREEDNS4.REGISTRAR-SERVERS.COM
   Name Server: FREEDNS5.REGISTRAR-SERVERS.COM
   Status: clientTransferProhibited
   Status: clientUpdateProhibited
   Updated Date: 20-nov-2013
   Creation Date: 05-feb-2012
   Expiration Date: 05-feb-2019

>>> Last update of whois database: Fri, 21 Nov 2014 01:59:03 GMT <<<

In this case, there are five authoritative name servers, so we'll query the first server, ' FREEDNS1.REGISTRAR-SERVERS.COM'.

$ dig a chrisburge.net @FREEDNS1.REGISTRAR-SERVERS.COM

See below for the results:

; <<>> DiG 9.8.5-P1 <<>> a chrisburge.net @FREEDNS1.REGISTRAR-SERVERS.COM
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59557
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;chrisburge.net.   IN A

;; ANSWER SECTION:
chrisburge.net.  1800 IN A 198.58.107.11

;; Query time: 151 msec
;; SERVER: 62.210.149.102#53(62.210.149.102)
;; WHEN: Thu Nov 20 20:02:26 CST 2014
;; MSG SIZE  rcvd: 48

Notice the 'aa' flag on this response, which means this answer is authoritative, unlike our first 'dig' query. The value of 1800 is the TTL value for the 'A' record for chrisburge.net.

Add new comment