Flow to update Cloudflare DNS records with current IP address

In case anyone finds it useful, I have added a flow to the node-red flows site that interrogates Cloudflare DNS records and automatically updates them where necessary.
I have used a request to http://ipinfo.io/ip to determine the current external IP address, but I don't know whether there are significant limitations to its validity, so any input on that would be useful.
https://flows.nodered.org/flow/514685740c0d68ac0421210cc81ad573

3 Likes

colin

Wow! I wasn't expecting that...

A half, or more, of the nodes are involved in detecting and reporting all the various errors that might occur, along with showing status.

I've been using a similar solution;

colin

Although it hasn't given me any problems over the past 3-4 years, my flow isn't as comprehensive as yours, and has no error checking :sleepy:
I don't check if the IP has changed before updating the cloudflare server, I just update it every 15 minutes regardless (I checked with the cloudflare team, and they said that was perfectly acceptable).
My api key, etc, are hardcoded in the curl script, in the template node.
Also, I use https://api.ipify.org/ to obtain my ip, which has proved very reliable.

As always, nice job Colin.

Does that just do one domain? Which is fine if that is all you need of course.

I didn't like the idea of the API key being visible in the source. I have put it in a password type field in the subflow properties.

That's cheating :slight_smile:

1 Like

An advantage of doing the DNS record lookup in Cloudflare is that it tells you the record ID, saving the user the effort of trying to find that. Having done the lookup it is then easy to check whether the IP is already correct.

I just did a lookup once, when I first created the flow, and then hard coded the record ID in the script, to avoid future duplicity.

Yes, but you had to work out how to do that. While I was trying to work it out, google found a very helpful request on the cloudflare forum for advise on how to do that, from someone whose name I am sure I recognised. :slight_smile:

1 Like

This is great work! The cloudflare integration in home assistant stopped working since the IP-detection returns IPv6 addresses… so glad I found this flow to update the records with node red instead.

I got this flow working using the Global API key — maybe worth mention that on the flow page. I created a scoped API key to read and edit zones (which is what the HA integration used), but that is not enough.

This is fantastic. Thank you again for your contribution

2 Likes

Thanks, I am glad it has been useful. As you suggested, I have updated the description to indicate Global API key.

If you felt so inclined you could rate the flow on the node red flows site.

1 Like