Change the TTL value of all domains

The best practice to migrate a website with less downtime is to change the TTL value to a lower one.

You can change the TTL of your domains from control panel Dns Manager

If you want to migrate too many domains it would be hard to change each domains TTL manually here is an easy way to change TTL of many domains

First backup all your DNS zone files

cp -rf /var/named /var/named_ttl_backup

No, we have a backup of all zone files under /var/named_ttl_backup

Let’s change the TTL value of all domains under /var/named

Change directory to /var/named

cd /var/named

Suppose that your current TTL value is 14400 and we are going to change it to 3600

perl -pi -e ‘s/14400/3600/’ *.db

This command will change all the TTL value of domains from 14400 to 3600

Reload named service

rndc reload

We are done 🙂

Monthly server support with Unlimited tickets, 24×7 monitoring, Security Audit and lot more for just $59