I've been trying to figure out a reliable way to find out the various TTL values for different DNS records on unix.
To clarify, what I want to find is the actual TTL, not the cached TTL values.
For example, google.com's A record has a TTL of 300 seconds. The same record has been cached on my system, with a TTL value of 96 seconds. What I want to find is the 300 second, not the 96 seconds.
So far I've tried using the following:
nslookup -query=SOA google.com | grep 'origin' # Find authoritative name server of domain
# origin = ns1.google.com
dig +nocmd +noall +answer @ns1.google.com www.google.com # Find TTL value of subdomain
# www.google.com. 300 IN A 74.125.130.106
This works fine, but is there a better alternative that is faster or better yet, allows me to list all the dns records under a specified primary domain and their TTLs?