[Support] Kilrah/Cloudflare-DDNS-config


Recommended Posts

[Template only, I am not the container author/maintainer]

 

Template: https://github.com/kilrah/unraid-docker-templates/blob/main/templates/cloudflare-ddns-config.xml

Source container: https://github.com/timothymiller/cloudflare-ddns

Registry: https://hub.docker.com/r/timothyjmiller/cloudflare-ddns

 

I've moved my DNS to Cloudflare, and found out that ddclient which I was using before just does not work anymore with Cloudflare's current API. There are already a few Cloudflare-DDNS containers in CA but they all have you enter settings as template variables, which makes it either impossible or impractical to enter multiple zones and a large number of subdomains. Looked for something more suitable to my situation and found timothymiller's container that works off a JSON config file that is a lot more manageable in such cases.

 

Important:

As this container uses a file mount for the config file before installing/running it you need to preload a sample config, in Unraid's terminal:

mkdir /mnt/user/appdata/cloudflare-ddns-config

wget -qO /mnt/user/appdata/cloudflare-ddns-config/config.json https://github.com/timothymiller/cloudflare-ddns/raw/master/config-example.json

 

And obviously edit it to your needs.

 

If you started the container without doing that first Docker will create a folder, you have to stop the container, delete the folder and get the file before restarting.

 

 

Edited by Kilrah
Link to comment

It should be left running in the background and it will check IP/update if necessary every 5 minutes.

 

EDIT: Looks like the container got an update a few hours ago to fix an issue with the root domains but got broken in the process.

EDIT2: Was fixed a couple of days later.

Edited by Kilrah
Link to comment

Hi Friends,

Thank you for maintaining this container.

I'm a noob so my question might seem obvious to programmers, but can someone, please, share an example of the config-example.json file that includes info for two different domains?

I saw the sample example-config.json file listed in the OP, but from what I understand it only includes info for 1 domain, so I'm not sure how to add the info of a second domain.

Hope someone can help 🙏

 

Link to comment

You basically duplicate the whole thing inside the "cloudflare" block, based on the author's sample:

 

{
  "cloudflare": [
    {
      "authentication": {
        "api_token": "api_token_here",
        "api_key": {
          "api_key": "api_key_here",
          "account_email": "your_email_here"
        }
      },
      "zone_id": "your_zone_id_here",
      "subdomains": [
        {
          "name": "",
          "proxied": false
        },
        {
          "name": "remove_or_replace_with_your_subdomain",
          "proxied": false
        }
      ]
    },
    {
      "authentication": {
        "api_token": "2nd_api_token_here",
        "api_key": {
          "api_key": "2nd_api_key_here",
          "account_email": "your_email_here"
        }
      },
      "zone_id": "your_2nd_zone_id_here",
      "subdomains": [
        {
          "name": "",
          "proxied": false
        },
        {
          "name": "remove_or_replace_with_your_subdomain",
          "proxied": false
        },
        {
          "name": "remove_or_replace_with_another_subdomain",
          "proxied": true
        }
      ]
    }
  ],
  "a": true,
  "aaaa": true,
  "purgeUnknownRecords": false
}

You'll typically only use one of the 2 authentication methods, remove the other one

Edited by Kilrah
  • Like 1
Link to comment
10 minutes ago, Kilrah said:

You didn't read the "important" note from the template/first post. Stop the container, delete the config.json folder and download the sample file.

Thanks for the clarification 🙏

The "important" note in the OP actually doesn't say to delete the folder. That's why I asked :)

Link to comment
5 minutes ago, Kilrah said:

Well no because it says "before running the container" precisely so that wrong folder doesn't get created.

If I'm not mistaken, UnRAID automatically tries to start new docker containers once their installation process is finished. 

I assume that's why the folder was already there, when I tried to follow the important note directions.

Because I didn't ran the container.

 

Edit: Ohhhhhhhh now I see you meant that we need to run the important note commands even *before installing* the container.

I thought I needed to run the important note commands after installation but before running the container.

My bad. Sorry for missing this 🙏🙏

Edited by mjeshurun
Link to comment
6 minutes ago, mjeshurun said:

If I'm not mistaken, UnRAID automatically tries to start new docker containers once their installation process is finished. 

Yes, hence 

 

On 7/26/2022 at 12:32 PM, Kilrah said:

before installing/running it you need to preload a sample config

 

  • Like 1
Link to comment

I'm seeing an error message in the container log:

error reading config.json

 

Did I make a mistake filling my info?

 

{
  "cloudflare": [
    {
      "authentication": {
        "api_token": "***************",
      },
      "zone_id": "eatingheads.com",
      "subdomains": [
        {
          "name": "",
          "proxied": true
        },
        {
          "name": "www",
          "proxied": true
        }
      ],
    },
    {
      "authentication": {
        "api_token": "******************",
      },
      "zone_id": "vicktoriasmirnoff.com",
      "subdomains": [
        {
          "name": "",
          "proxied": true
        },
        {
          "name": "www",
          "proxied": true
        }
      ],
    },
  ],
  "a": true,
  "aaaa": false,
  "purgeUnknownRecords": false
}

 

Link to comment

There are a few stray commas, basically the last element in a block must not have one. Try this...

 

{
  "cloudflare": [
    {
      "authentication": {
        "api_token": "***************",
      },
      "zone_id": "eatingheads.com",
      "subdomains": [
        {
          "name": "",
          "proxied": true
        },
        {
          "name": "www",
          "proxied": true
        }
      ]
    },
    {
      "authentication": {
        "api_token": "******************",
      },
      "zone_id": "vicktoriasmirnoff.com",
      "subdomains": [
        {
          "name": "",
          "proxied": true
        },
        {
          "name": "www",
          "proxied": true
        }
      ]
    }
  ],
  "a": true,
  "aaaa": false,
  "purgeUnknownRecords": false
}

 

Link to comment
  • 3 months later...

If i may suggest everyone will start it first and will have the same problem, you could have saved some ppl some time and just write to it, "if you startet it before creating, remove folder." ;-)

 

Its very unusual that you need to do it before installing.

 

Could also be automatic be done?

 

and just btw, your provided config is (still) not working. you cant leave out the api key. but still twith that, it wont work. (i didnt found a working solu tion for multiple domains, and even the documentation doesnt show an example...)

Edited by nuhll
Link to comment

Ha i found it

 

{
  "cloudflare": [
    {
      "authentication": {
        "api_token": "XXXXXX",
        "api_key": {
          "api_key": "api_key_here",
          "account_email": "your_email_here"
        }
      },
      "zone_id": "XXX",
      "subdomains": [
        {
          "name": "",
          "proxied": true
        },
        {
          "name": "www",
          "proxied": true
        },
		{
          "name": "forum",
          "proxied": true
        }
      ],
	  "zone_id": "XXXXXX",
      "subdomains": [
        {
          "name": "",
          "proxied": true
        },
        {
          "name": "www",
          "proxied": true
        }
      ]
    }
  ],
  "a": true,
  "aaaa": true,
  "purgeUnknownRecords": false,
  "ttl": 300
}

 

Link to comment

I have one "authentication" section for each zone and it's fine. 

 

{
  "cloudflare": [
    {
      "authentication": {
          "api_token": "auth1"
      },
      "zone_id": "zone1",
      "subdomains": [
        {
            "name": "",
            "proxied": false
        },
        {
            "name": "sub1",
            "proxied": false
        }
      ]
    },
    {
      "authentication": {
          "api_token": "auth2"
      },
      "zone_id": "zone2",
      "subdomains": [
        {
            "name": "",
            "proxied": false
        },
        {
            "name": "sub1",
            "proxied": false
        },
        {
            "name": "sub2",
            "proxied": false
        }
      ]
    },
    {
      "authentication": {
          "api_token": "auth3"
      },
      "zone_id": "zone3",
      "subdomains": [
        {
            "name": "",
            "proxied": false
        },
        {
            "name": "sub1",
            "proxied": false
        }
      ]
    }
  ],
  "a": true,
  "aaaa": false,
  "purgeUnknownRecords": false,
  "ttl": 300
}

 

Edited by Kilrah
  • Like 1
Link to comment
On 2/13/2023 at 2:39 PM, Kilrah said:

I have one "authentication" section for each zone and it's fine. 

 

{
  "cloudflare": [
    {
      "authentication": {
          "api_token": "auth1"
      },
      "zone_id": "zone1",
      "subdomains": [
        {
            "name": "",
            "proxied": false
        },
        {
            "name": "sub1",
            "proxied": false
        }
      ]
    },
    {
      "authentication": {
          "api_token": "auth2"
      },
      "zone_id": "zone2",
      "subdomains": [
        {
            "name": "",
            "proxied": false
        },
        {
            "name": "sub1",
            "proxied": false
        },
        {
            "name": "sub2",
            "proxied": false
        }
      ]
    },
    {
      "authentication": {
          "api_token": "auth3"
      },
      "zone_id": "zone3",
      "subdomains": [
        {
            "name": "",
            "proxied": false
        },
        {
            "name": "sub1",
            "proxied": false
        }
      ]
    }
  ],
  "a": true,
  "aaaa": false,
  "purgeUnknownRecords": false,
  "ttl": 300
}

 

 

Hi @Kilrah, thank you for posting an example of your config file.

I'm seeing the following error message repeatedly in the container's log, when I try to build my config file based on yours. Obviously, I used my own api-token and zone address.

For the sake of privacy I change the actual zone address in the log error quote to "********.com".

😡 Error sending 'GET' request to 'https://api.cloudflare.com/client/v4/zones/********.com':
{"result":null,"success":false,"errors":[{"code":7003,"message":"Could not route to /client/v4/zones/********.com, perhaps your object identifier is invalid?"}],"messages":[]}

 

Do you have any idea why this error is happening?

Link to comment
8 hours ago, Kilrah said:

I do get some occaisional Service Unavailable and other 404 and errors in the logs, seems the CF service isn't extremely reliable... 

See if it gets better with time. Of courrse check your zone id/token and that the token has the correct permissions on the zone.

 

I've double checked my zone_id and the api_token password and they are correct.

Are these the correct token permissions I should set?

Zone Settings:Read, Zone:Read, DNS:Edit

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.