Cloudflare Dynamic DNS (DDNS) Updater Addon

Hi all

Since having major issues with DuckDNS as CNAME for my primary domain, I personally chose to go a more mature route and use Cloudflare for DNS and update the A record it directly.

I looked around and only found outdated add-ons from 2019, so I chose to roll my own addon using the cloudflare recommended ddclient project for updating Cloudflare DNS records automatically. I’ve wrapped that up into an addon that you can install from my repository:

GitHub - silashansen/hass_addons: Addon repository

Enjoy!

7 Likes

Thank you greatly for your work on this.

One minor typo on your installation instructions that may be tripping up some people.

Step 3 has a dash instead of an underscore in the URL. The correct URL to add is:

Until I realized this, I was going nuts clearing my cache in order for the Addon to show up. And surprisingly no error in HA when adding an invalid URL.

Ah… I see what is going on now… You have S3 in hass-addons and Cloudflare in hass_addons… You might want to consolidate those two under hass-addons

Yes, same problem here. And the repository.json file also has the dash instead of an underscore, so even if yo uspecify the addon repository correctly you still end up getting the other (Amazon S3) addon.

Hi guys

That is a crazy mistake and happens to hit another repo that I have previously forked. Thanks for pointing it out :pray: I have fixed it now!

Thanks for the nice addon. Works for me now.

1 Like

Can this be updated for DDNS IPv6 (AAAA) support?
As my Home Assistant uses a public delegated IPv6 address as my internet povider is a mobile operator (SIM Card) which often only gives you an IPv6 which is globaly routable. http://checkipv6.dyndns.com

1 Like

There is also the official Cloudflare - Home Assistant integration but that too lacks IPv6 support

I have found a workaround I am happy with. first, set up the DNS IP integration, and if you want to copy paste the config name the ipv6 sensor sensor.myip_ipv6. than go to your cloudflare, and take note of your zone id(can be found in the overview page), also create an api token with Edit zone DNS and the zone of your doamin. take note of this key also. open the command line an type the follwing:

$ZoneID = "zone id"
$Token  = "api key"
$Domain = "your.domain.com"
(Invoke-RestMethod -Method GET -Uri "https://api.cloudflare.com/client/v4/zones/$ZoneID/dns_records?type=AAAA&name=$Domain" -Headers @{ "Authorization" = "Bearer $Token"; "Content-Type" = "application/json" }).result[0].id

the output is your record id.
than add to your configuartion.yaml:

rest_command:
  update_cloudflare_ipv6:
    url: "https://api.cloudflare.com/client/v4/zones/{zone id}/dns_records/{record id}"
    method: PUT
    headers:
      Authorization: "Bearer {api token }"
      Content-Type: "application/json"
    payload: >
      {
        "type": "AAAA",
        "name": "your.doamin.com",
        "content": "{{ states('sensor.myip_ipv6') }}"
      }

make sure to repalce {zone id}, {record id}, {api token } and ““your.domain.com””(also sensor.myip_ipv6 if you choose a diffrent name). restart home assistant, you should now have an action called “update_cloudflare_ipv6” make an autoamtion like this:

alias: IPV6 DDns
description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.myip_ipv6
    attribute: ip_addresses
conditions: []
actions:
  - action: rest_command.update_cloudflare_ipv6
    metadata: {}
    data: {}
mode: single

Done!