statox
statox

Reputation: 2896

Improve DNS propagation by changing TTL

The public IP adress of my home is a dynamic IP and I need to access it from outdoors. I didn't want to use services like DynDns or NoIp so I made my own script.

The script is executed each hour, basically it reads my public IP on icanhazip.com, and the IP corresponding to mydomain.com (using the python tool dnsyo). If the adresses are differents, it uses cloudflare API to link my new public IP to mydomain.com.

My problem is that when the IP change I have to wait aproximatively 5h before the propragation of the DNS. During this time, mydomain.com resolves my old public IP so I can't access the new one.

My question is: how can I make this propagation faster?

I saw there (section 3.7) that I can change the Time To Live parameter of my dns zone, if I reduce this variable, will it reduce the propagation time or will it just mess my settings? And if I change it what is a reasonable value to set?

Upvotes: 2

Views: 2181

Answers (1)

kiko
kiko

Reputation: 180

The DNS TTL is the number of seconds during which caching nameservers are allowed to cache a query result. In general the practical consequence of this is that clients may see stale values for up to that that duration. Reducing the TTL is exactly how people handle DNS entries that change frequently (or which are about to change).

You can check to see whether this is actually the issue by checking what the TTL value is when querying the authoritative DNS server (I assume Cloudflare in your case) directly:

% host -v dynamic.foo.com ns.foo.com
Using domain server:
Name: ns.foo.com
[...]
dynamic.foo.com. 1800   IN  A   10.10.1.1

1800 is 30 minutes, so clients that requested dynamic.foo.com just before the update happened may see stale values for up to that duration.

If you are using CloudFlare's rec_edit action as documented in https://www.cloudflare.com/docs/client-api.html#s5.2 then you can specify the TTL for that specific record, as opposed to for the entire zone. That is likely what you want.

Upvotes: 1

Related Questions