Important
This Project is currently work in progress and not finished yet!
Link to old project (still works fine). I am currently rewriting this project from vanilla JS to TS. I also want to improve the documentation and functionality.
Update your Cloudflare DNS records from your Fritz!Box.
Many ISPs often only offer a dynamic IP for the home connection or charge a lot of extra money for a static IP address. In most cases, a static IP is not required, but if you want to offer a service from your own home via your home connection, there is often no way around a static IP. However, there is an alternative to a static IP, and that is DynDNS. Using a DynDNS you can automatically update a name server in the Domain Name System (DNS). This means that if the IP of your home connection changes, the router can notify the name server of this change.
AVM does already provide a build-in DynDNS service for the Fritz!Box, called MyFritz, why not use the build-in service instead? I don't want all my traffic to be routed between multiple diffrent services. I already manage my domains on Cloudflare, so why use another service when I just can manage everthing on Cloudflare.
This project was developed especially for the Fritz!Box by AVM, but the worker can also be used for other routers that support DynDNS.
If the IP is changed by the ISP, the Fritz!Box sends a GET request to the DynDNS URL. The Fritz!Box offers various placeholders for the URL which are automatically filled in by the Fritz!Box before sending.
The worker which is behind the URL is executed by the GET request of the Fritz!Box and changes the IP which was given via the URL parameters using the Cloudflare API.
Parts of the update URL:
https://worker.username.cloudflare.dev/?token=xyz123&zoneId=abc123&record={"type":"A","content":"000.000.000.000","name":"example.com","proxied":false,"comment":"Updated by Fritz!Box DynDNS","ttl":100}
├────┘ ├──────┘ ├─────────────┘ ├──────────┘ ├───────────┘ ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
│ │ │ │ │ └ The record to create/update (JSON format)
│ │ │ │ └ The zone ID of your domain
│ │ │ └ The API token
│ │ └ The Cloudflare base URL
│ └ Your Cloudflare username
└ Your worker instance name
Furthermore, there are a few placeholders which are automatically replaced by the Fritz!Box:
Parameter | Description |
---|---|
<username> |
Username |
<pass> /<passwd> |
Password (Token) |
<domain> |
Domain |
<ipaddr> |
New IPv4 address of the Fritz!Box |
<ip6addr> |
New IPv6 address of the Fritz!Box |
<ip6lanprefix> |
IPv6 prefix for home network |
<dualstack> |
Dual-stack |
<b64> ... </b64> |
Base64 encoded Data |
More information can be found in this knowledge base from AVM on the topic "2 Setting up dynamic DNS".
The build worker.js
file can be found inside of the worker/
directory.
The following properties can be specified for each record to create/update.
Parameter | Valid Value | Description |
---|---|---|
type |
A /AAAA /CNAME |
Type of the record. |
content |
string | String value representing the content for the record. Ex. IP for A record: XXX.XXX.XXX.XXX |
name |
string | Your domain. Ex. example.com |
proxied |
true /false |
If the record should be proxied by Cloudflare. You can find more information in the Cloudflare documantation about "Proxy status" |
comment |
string (character limit) | A comment for this record. |
ttl |
number/auto |
Time to live (TTL). |
- Record<Type>
- type : Type
- content : string
- name : string
- proxied : boolean
- comment : string
- ttl : number
{
"type": "A",
"content": "000.000.000.000",
"name": "example.com",
"proxied": false,
"comment": "Updated by Fritz!Box DynDNS",
"ttl": 100
}
https://worker.username.cloudflare.dev/?token=xyz123&zoneId=abc123&record={"type":"A","content":"000.000.000.000","name":"example.com","proxied":false,"comment":"Updated by Fritz!Box DynDNS","ttl":100}