You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why I did even wrote this script in the first place? There is already a service from AVM (the company behind Fritz!Box) called MyFritz! which does exactly that... Well, since I manage my domains with Cloudflare, I wanted to avoid an extra service where I need an extra account again. And since I already manage my domains via Cloudflare, I chose a Cloudflare Worker.
If you already have a MyFritz! account from AVM and you are using this account actively, then you can use their own DynDNS service, which is provided directly by AVM.
What even is a Cloudflare Worker?
A Cloudflare Worker is basically just a script that is stored under a certain URL and is executed when this URL is called. Or rather, that's what we use it for. Cloudflare Workers can do so much more. For more info, check out this overview to see what else you can use Cloudflare Workers for.
Getting started
Okay, but now let's begin. In this guide I will explain how you can set up your own DynDNS service using a free Cloudflare Worker. I will go into all the steps that are necessary to create the Worker and how to set the service up correctly.
After you log in/register you should land on your dahboard. On the left hand side you should now see a menu point called "Workers". Click on this item. When you create a worker for the very first time you will land on the example page with the "Hello World sample worker" which looks something like this:
Click on "Create Worker" below.
Edit Worker
Then after that you will be taken directly to the "Quick Edit" view of the created Worker. On the left side you can see which code is executed inside the Worker. That means which code is responsible for our DynDNS service in the end. Now delete the code template example that was automatically added when you created it and replace it with the code from this repository.
After replacing the template with the code from the repository, click on the "Save and deploy" button at the bottom. If you have done everything right, you should be automatically returned to your account home page. Going again back to the left side in the menu under Workers, you should see your newly created Worker.
Quick-Edit existing Worker
You can edit your worker at any time using the "Quick edit" button.
Changing Sub-Domain for Workers
You can also change the sub-domain for all the Workers for your account. To do this, go back to the home page for all workers. Then on the right side you can change the sub-domain.
Get and configure Cloudflare API Token
Next, we'll look at how you can generate an API token for your Cloudflare account. To do this, log into your account and go to your profile, at dash.cloudflare.com/profile.
Now we will create a new API token. If you already have an API token from Cloudflare and it has the necessary permissions, then you can use this token.
Click on "Create Token"
Next, we will create a "Custom token" with the necessary permissions. To do this, click on Create Custom Token "Get started".
Give the token a name and then set these permissions for the token. You can also add more permissions, the important thing is that the token can be used to access your zone or the gateway API in the end.
Confirm the settings by clicking on "Continue to summary" below.
Your summary should look similar to this. If so click on "Create Token"
Now you can copy your token and use it for the Worker.
Using the script/request URL
Next, we'll look at how to properly use the Worker's request URL. We will also take a look at how to correctly enter the update URL into your Fritz!Box.
Basic URL structure
Let's look at the basic structure of the request URL. The URL is structured as follows:
Worker subdomain
Account name
Cloudflare Worker domain
<subdomain>
<name>
workers.dev/
An example would look like this: https://random-name.your-account.workers.dev/
URL parameters
The following parameters can be used in the URL:
Parameter
Datatype
Required
Default Value
Description
token
string
yes
""
Token for the Cloudflare API
zoneid
string
yes
""
ID for the DNS Zone
ipv4address
string
yes
""
IPv4 address to update
ipv4name
string
yes
""
IPv4 domain name
ipv4proxied
boolean
no
true
If the IPv4 connection should be proxied
ipv4ttl
number
no
1
IPv4 Time to live (1 = Auto, 60-86400 = Valid range)
IPv6 domain name (*Only required if ipv6address is specified)
ipv6proxied
boolean
no
true
If the IPv6 connection should be prodied
ipv6ttl
number
no
1
IPv6 Time to live (1 = Auto, 60-86400 = Valid range)
comment
string
no
""
Comment for the created/updated record
Parameters are simply appended to the request URL with a ?. Between the parameters are & characters. For more information, please reference to this article from MDN on how to properly encode URL parameters.
Placeholders
Furthermore, there are a few placeholders which are automatically replaced by the Fritz!Box:
Device that sends the request (*This is not directly from Fritz!Box, it is implemented via the Worker script)
For more information please reference to this knowledge base from AVM on "2 Setting up dynamic DNS".
An example with the parameters would look like this: https://random-name.your-account.workers.dev?token=abc1234&zoneid=1234&ipv4address=<ipaddr>&ipv4name=example.com&comment=This%20is%20a%20comment
Or with more placeholders: https://random-name.your-account.workers.dev?token=<passwd>&zoneid=<username>&ipv4address=<ipaddr>&ipv4name=<domain>&comment=This%20is%20a%20comment%20from:<useragent>
Now you can put your credentials inside the password and username field.
About
A simple Cloudflare Worker script to update your IP address using the build-in Fritz!Box DynDNS