Lowering only specific DNS records TTL

, ,

Hi all,

there is this very old but still valid (I hope) great post about how to lower the TTL for all DNS records prior to a migration: http://forums.interworx.com/threads/1582-Advice-Needed-IP-Migrations?p=9815#post9815

I am not a SQL guy at all, so my question is instead of

UPDATE dns_records SET ttl=200;

I would like to only change those TTL value, that are still on the default of 43200 seconds.

I know there is the CASE statement for SQL, but I can’t write the correct SQL statement. In natural language it would be:

Update all DNS-Records to 200 IF they currently are 43200 ELSE do nothing

Can anybody help me with the correct statement?

Thanks,
Michael

Hi Michael

Sorry, I’m missing something here sorry, but why do you not set TTL the same for all records

TTL set at 200 is extremely low as well, Microsoft set theirs at 3600. Sorry if you were just showing for example though

I’ll have to have a think but I’m sure it’s possible

Many thanks and have a lovely bank holiday

John

Hi John,

as in the linked post, lowering the TTL is only temporary. You lower it to something very low like 200, wait a day or two, THEN migrate a domain or in this case all domains to another server/IP and the changes SHOULD be propagating very quickly through the internet because of the low TTL. Then, afterwards, you raise the TTL again to it’s original value. And that’s also the reason for wanting to lower only specific TTL. Office 365 DNS entries should be at 3600 as you described. There are some other records, that have to be lower for one reason or the other. So after the migration you don’t want to raise all those to the default 43200 but keep them on 3600 etc. To do that I need to “target” specific values, lower them to secific values and afterwards raise them again to the original value.
E.g.
43200 -> 200 -> 43200
3600 -> 201 -> 3600

So John, if you don’t speak Chinese, do you speak SQL fluently by any chance? :smiley:

Hi Michael

Haha how true, just have a look at http://status.pulsant.com. Life just goes that way sometimes.
I would not say I’m fluent, but here you go, try this (it works on mysql 5.5, so should work for you I believe - sorry, I do not have Mariadb)
I hope that helps and have a lovely bank holiday
Many thanks
John
UPDATE dns_records
SET ttl= IF(ttl = 200, 43200, IF(ttl = 1000, 1200, ttl))
this may work as well, because above changes 2 options
UPDATE dns_records
SET ttl= IF(ttl = 43200, 200, ttl)