brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: dig +ttlunits makes TTLs readable

Dig
~/tips/tip-dns-dig-ttlunits

dig +noall +answer +ttlunits example.com

Prints DNS record TTLs as minutes, hours or days instead of raw seconds.

A TTL of 86400 is a day. A TTL of 3600 is an hour. A TTL of 2592000, though, makes me reach for a calculator.

+ttlunits prints the TTL with the units dig knows: seconds, minutes, hours, days and weeks.

dig +noall +answer +ttlunits example.com

So you read 1d or 5m instead of counting zeros. The manual notes that it implies +ttlid, which only means the TTL column is printed in this form.

It is a small switch, but I like it when I compare records before a migration. You see in one look which records can be flipped quickly and which will hang around in caches for days. If you use it all the time, you can put it in a ~/.digrc file next to your other favourite options. Check your dig version with dig -v first: the option is not in very old builds.

It combines well with the other display switches. +noall +answer +ttlunits gives you one clean line per record with a readable TTL. I would paste that version into a ticket or a chat message.

Further reading: dig manual (BIND 9), On this site: run dig twice and watch the TTL count down, On this site: dig can speak DoH and DoT itself

Going deeper: Guide: dig for beginners, look up DNS records and read the answer

More Dig tips dig +noall +answer DS example.com dig nope.iana.org @9.9.9.9 | grep -E 'status|SOA' dig +search nas dig @8.8.8.8 www.google.com +subnet=203.0.113.0/24 dig +yaml example.com A All Dig tips (36) All topics

Link