When moving web host to another hosting service’s server or changing the server’s IP address, one of the important consideration to ensure to continue availability of the websites hosted on the server, minimize the downtime of the web sites, avoid weird problems such as emails get delivered to either server randomly, or browsing at old server, is how fast DNS (Domain Name System) will be able to translate or resolve hostname or domain name into your new IP address, instead of the old IP destination. Unfortunately, webmasters have limited ability to control or override the DNS propagation process. Nonetheless, there are still some tips, tricks and workarounds that ensure DNS cache will reflect the new IP addresses as soon as possible.

DNS works in such as a way that when a request for IP address received by DNS resolver, it will then query the root servers to find the authoritative server with detailed knowledge of the particular domain name. If a valid IP address for the domain is returned by the authoritative server, the DNS resolver will cache the DNS resolution for a given period of time known as TTL (Time To Live) after a successful answer, in what known as DNS caching in order to reduce the load on particular DNS server. DNS caching allows resolution of domain name to IP to take place locally using the cached information instead of querying the remote server for subsequent requests, until the TTL duration expires.

The Time-To-Live (TTL) timer is the trick to ensure that the DNS cache expires quickly and always stays fresh. TTL is defined by domain administrator in the authoritative DNS server for the zone where data originates, and its values instruct DNS caching resolvers to expire and discard the DNS records after TTL seconds. Lowering the TTL value will enable rapid expiration and refreshing of DNS records, causing the new records to propagate faster across the world. However, the trick needs the name resolvers follow the RFC standards, which most do. Beside, you must have full control to modify the name server authoritative for your domains.

The tweaking of TTL in DNS records must be done a few days before it’s about to change (date of server moving or IP change) to ensure that all DNS caching resolvers receives the new TTL value and expires the old longer value. The trick will reduce the TTL in anticipation of the change to minimize inconsistency during the change, according to RCF 1034.

TTL is defined by Minimum field in SOA (Start of Authority) type as default TTL, or individually at each record as TTL. RCF 1912 describes the Minimum field in details as below:

Minimum: The default TTL (time-to-live) for resource records (RR) — how long data will remain in other nameservers’ cache. ([RFC 1035] defines this to be the minimum value, but servers seem to always implement this as the default value) This is by far the most important timer. Set this as large as is comfortable given how often you update your nameserver. If you plan to make major changes, it’s a good idea to turn this value down temporarily beforehand. Then wait the previous minimum value, make your changes, verify their correctness, and turn this value back up. 1-5 days are typical values. Remember this value can be overridden on individual resource records.

If you’re using a web-based or graphical user interface to manage your domain’s DNS records, then login to the system, and edit the SOA records. Inside you will see a field named Minimum, modify the value to as low as possible (in seconds), such as 300 for timeout every 5 minutes. Then modify the TTL for all of the A, AAAA, MX, CNAME, TXT, SOA, PTR and other records, if applicable.

If you are using cPanel WebHost Manager (WHM), login and choose Edit DNS Zone under DNS Functions section. Select the applicable zone (domain name). You will be presented with a list of records. Modify the minimum ttl in SOA, and TTL column of A, MX, CNAME and other records defined.

For those manually configure the authoritative nameserver for a domain zone using BIND, modification has to be done in the zone file. For example, so domain zone example.com, you will see the following resource records in the zone file:

; zone 'example.com'
$TTL 14400

@     IN     SOA     ns1.example.com. host.example.com. (
2007080501      ; Serial
10800           ; Refresh 3 hours
3600            ; Retry 1 hour
604800          ; Expire 1 week
86400          ); Minimum 24 hours

@                       NS      ns1.example.com.
@                       NS      ns2.example.com.

@                       A       192.168.0.1
@                       MX     10 mail.example.com.

; nameservers
ns1                     A       192.168.0.11
ns2                     A       192.168.0.12
; mail servers
mail                    A       192.168.0.10
; web server
www                     CNAME   example.com.

Now change the $TTL 14400 with the value you want (in seconds), such as 300 (5 minutes). This value defines the default TTL of all existing records, and by lowering this value to 300 (for example, you can choose your won value), caching server will be hold this records for more than 5 minutes before querying the authoritative name server which will be the first to reflect the new IP address when change later on again. Another value that you should change is minimum TTL, the last line of SOA type (remarked as minimum 24 hours).

After change, your DNS zone file will probably looks like this:

; zone 'example.com'
$TTL 300

@     IN     SOA     ns1.example.com. host.example.com. (
2007080501      ; Serial
10800           ; Refresh 3 hours
3600            ; Retry 1 hour
604800          ; Expire 1 week
300            ); Minimum 24 hours

@                       NS      ns1.example.com.
@                       NS      ns2.example.com.

@                       A       192.168.0.1
@                       MX     10 mail.example.com.

; nameservers
ns1                     A       192.168.0.11
ns2                     A       192.168.0.12
; mail servers
mail                    A       192.168.0.10
; web server
www                     CNAME   example.com.

Restart the DNS service. The new TTL value will propagate to other DNS nameserver. This process typically takes 48 hours to 72 hours (hence the need to reduce TTL to try to make it faster when changing the critical A and MX records). After waiting for a few days, move your websites to new server or change the IP address, and then update the DNS records to point to the new server or IP.

Once done, you can now revert back the TTL values to reduce the load on your DNS server.