Cloudflare DynDNS dual wan

I have dual wan setup and want to update the DNS with both IPs. Currently my problem is that wan1 IP replaces wan2 IP in DNS and the way around. I wanted to seperate the scripts so it does always update the IP only for one interface and than use a cname to point to both subdomains but that is not possible. Does somebody have a idea how to have both IPv4 and IPv6 adresses in DNS so clients loadbalance between them?

Thanks for help

The API does let you specify the specific DNS record identifier you’re updating.


For having both: IPv4 and IPv6 set up as dynDNS I would prefer the “DualStack” script from here:

Also I have not tested the script on a DualWAN setup but this should not break functionality.
Keep in mind that you maybe have to replace the Authentication String in the from from:

  1. -H "X-Auth-Key: $auth_key"
  2. -H "Authorization: Bearer $auth_key"
    according to the new API v4 requrements:
    Cloudflare API v4 Documentation

At least thats AFAIK the thing I had to change back when I set this up some time ago.
If you have to set this up for two different domains which both should have IPv4 and IPv6 as dynDNS then just duplicate the script and change record_name for the other script to fit your needs.

I even had to excape all of these " which made my updatecommand look like this:

update=$(curl -s -X PUT "$zone_identifier/dns_records/$record_identifier" -H "X-Auth-Email: $auth_email" -H "Authorization: Bearer $auth_key" -H "Content-Type: application/json" --data "{\"id\":\"$zone_identifier\",\"type\":\"A\",\"proxied\":false,\"name\":\"$record_name\",\"content\":\"$ip\",\"ttl\":0}")

But IPv4 and IPv6 do not have anything directly to do with Loadbalancing. Please keep that in mind.

1 Like

The script is nice as a starting point to write my own one, but out of the box useless in a dual wan enviroment because it gets the IPs from a external source which allways see only one of the IPs.
The identifier posted by sdayman seems to be exactly what i needed, now i just need to find a way to use it.

It should get both IP addresses, as it queries for both IPv4 and IPv6 from icanhazip

I mean both IPv4 and both IPv6 addresses so in total 4 since it is dual wan and both connections are dual stack.

Ah, I see. If that’s the case, I’d see if there was a way to re-write the script to be able to pull both of your IPv4, and both IPv6, then skip the scan part and hardcode the DNS Record Identifiers into the script. This would require that the four records already exist in your DNS and you’ve queried the API for all your DNS records so you’d know those four identifiers.

That part i already made after looking at the API you posted.

Yeah that is the hard part, i need to run that on my router because there i have the IPs on the Interfaces to get and i can’t difference them on my server because both prefixes are on the same interface, but than i need to rewrite the suffix for IPv6. I think that will be to much for my basic scripting skills, but i will try and see how far i will get.

ok after looking at the logic needed for this i give up, I need to rewrite the suffix, i would have to delete the id if one connection goes down and than create it newly after it comes up again and store than the id to use it for updates again.

I’m not skilled enough to write a full blown solution for this, i have no clue how to add that much logic to a script. If somebody wrote a solution that handles that my deep respect and please point me to it :smile:

ok I had time to rewrite the script, it isn’t pretty and works only in a specific enviroment, also doesn’t have any error handling if one connection is down but maybe it is usefull for somebody to start off. GitHub - TheB1gG/systemd-cfddns: Bash-powered DDNS client for Cloudflare-managed domain

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.