/////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# /the/tech/blog
Solutions for FreeBSD web and application servers using PHP, mySQL, Apache and more.
Posted By Adam
Thursday, August 26th 2010

Adam StrohlHOWTO: Using dig(1) to Find DNS Time to Live (TTL) Values

The dig(1) command is a handy DNS information and troubleshooting tool. It can be used to grab a host or domain's TTL (time to live) values.

This information can be critical to planning a DNS cut over, and how long to leave the old server on.

In most circumstances I'd recommend running a low (5 minute or less) value for normal operation, but some ISPs and providers still are shy about decreasing these values so it is always a good idea to check.

TTL for a Specific Host

Dig's default output provides the TTL information, it is the number proceeding the record type (underlined below):

# dig +nocmd www.ateamsystems.com +noall +answer

www.ateamsystems.com.   270     IN      A     69.55.231.82

Note: If your default DNS server is not the authoritative server for the zone you are digging dig will show the time remaining (until the next refresh) instead of the raw TTL value in this position.

You can work around this by directing dig to specifically use one of the domain's servers, for example I know that ns1.ateamservers.com is authoritative for this domain:

# dig @ns1.ateamservers.com +nocmd www.ateamsystems.com \
    +noall +answer

-- SNIP --
www.ateamsystems.com.   300     IN      A     69.55.231.82

Default TTL (and negative-TTL) for a Domain

We can also pull the domain-wide TTL setting, which controls negative-TTLs (how long a server will cache an NX or 'nothing there' reply). This will also break out the SOA into an easier to read format:

# dig +nocmd ateamsystems.com any +multiline +noall \
    +answer

-- SNIP --
ateamsystems.com. \
     300 IN SOA ns.ateamservers.com. dns.ateamsystems.com. (
                       4007121214 ; serial
                       3600       ; refresh (1 hour)
                       900        ; retry (15 minutes)
                       2592000    ; expire (4 weeks 2 days)
                       300        ; minimum (5 minutes)
                       )

For more information on dig's many uses take a look at Paul Heinlein's DiG HOWTO.

Special thanks to James Snow who provided the initial facts and inspiration for this post.

loading icon

Fetching vote status, one moment ...

Add a Comment:

* Name:
* Email address:
Verification purposes only. Your email address will not be shown publicly, transfered, or sold. We don't spam and take data privacy seriously.
* Comment:
icon

Related Experience

Take a look at these related items:

ISC's BIND DNS Server

icon

Disclaimer

Any problems and their solutions discussed here are designed to be examples and may not exactly match your situation.

No warranty is provided or implied with these articles, if it's critical contact us: we support and guarantee all of our work.