How To: Lowering Your DNS TTLs

Posted on by J. Mays | Updated:
Reading Time: 2 minutes

Whenever making DNS changes, lowering your TTLs (Time To Live) 24 hours ahead of time will reduce the amount of time that your change takes to propagate.
This article assumes that you are running BIND on a Linux server, that you already have an understanding of what DNS is, the different types of DNS entries, and how DNS works. Please note: The incorrect editing of your zone file can take your site offline. All editing must be done on the authoritative nameservers for the given domain.

Why and when to lower your TTL

Typically, DNS changes are quite infrequent. You will normally only make IP address changes when performing a migration of your domain, or moving your domain’s email to another server or service. If you are getting ready to change your domains IP address, you should lower your TTL 24 hours in advance, to allow the TTL change to fully propagate throughout the DNS infrastructure of the internet.

Where to change your TTL, and what to set it to

Below you see a typical zone file:

;Zone file for liquidweb.com
$TTL 14400
@      86400    IN      SOA     ns.liquidweb.com. admin.liquidweb.com. (
2009022402      ; serial, todays date+todays
86400           ; refresh, seconds
7200            ; retry, seconds
3600000         ; expire, seconds
86400 )         ; minimum, seconds
liquidweb.com. 86400 IN NS   ns.liquidweb.com.
liquidweb.com. 86400 IN NS   ns1.liquidweb.com.
liquidweb.com.  IN A   209.59.139.21
localhost  IN A   127.0.0.1
liquidweb.com.  IN MX 0   liquidweb.com.
mail  IN CNAME  liquidweb.com.
www  IN CNAME   liquidweb.com.
ftp  IN A   209.59.139.21
cpanel  IN A   209.59.139.21
webmail  IN A   209.59.139.21

The specific part we are concerned about here is the $TTL 14400. This portion is called your Zone File’s Time To Live, or TTL, and is set in seconds. This indicates to all clients and caching nameservers how often it should check back with the authoritative nameserver for updated information.

Note: Caching nameservers will store the answer they get, and the Serial Number for the zone file. Make sure when you make any changes to your zone file, you increment the serial number.

Leaving this setting at the default of 14400 (4 hours) is fine, but when you are preparing for any event that will require an IP change, you can limit your downtime by lowering that value, so the caching servers will check back more frequently. Typically, 300 seconds (5 minutes) is good primary IP address changes.

To lower that value on the Linux Command Line

    1. Edit the zone file with your favorite command line editor.

[benny@host /var/named/]
: vi /var/named/example.com.db

    1. Change the value following the $TTL to the desired value.
    2. Update the Zone’s Serial number.
    3. Make BIND aware of your DNS changes by reloading the DNS zone.

[benny@host /var/named/]
: rndc reload example.com

    1. Test that your changes worked correctly using ‘dig’.

[benny@host /var/named/]
: dig @localhost example.com

Congratulations! Your TTLs have been lowered and you have taken the first step in preparing for your DNS change. Before making any other changes, or preparing to move your data, it is a good idea to make a backup of your site. Learn how.

===

Liquid Web’s Heroic Support is always available to assist customers with this or any other issue. If you need our assistance please contact us:
Toll Free 1.800.580.4985
International 517.322.0434
support@liquidweb.com
https://manage.liquidweb.com/

Avatar for J. Mays

About the Author: J. Mays

As a previous contributor, JMays shares his insight with our Knowledge Base center. In our Knowledge Base, you'll be able to find how-to articles on Ubuntu, CentOS, Fedora and much more!

Latest Articles

Blocking IP or whitelisting IP addresses with UFW

Read Article

CentOS Linux 7 end of life migrations

Read Article

Use ChatGPT to diagnose and resolve server issues

Read Article

What is SDDC VMware?

Read Article

Best authentication practices for email senders

Read Article