This is my custom dynamic domain name service (ddns) client. This only works with cloudflare currently, as it is the dns provider I am using. It shouldn't be too hard to add support for other providers.
The project is also currently only targeting debian, as it is the only operating system relevant to my use case. It shouldn't be too hard to add support for other operating systems, as this is a relatively simple program. Finding the current ipv6 address is the only thing that might be a bit tricky. In theory, the code might even be portable. I have not tested this however.
It is important to note, that right now the client does not differentiate between permanent and temporary IPV6 addresses. This is a non issue for webservers, but could apparently, in theory, be an issue for long connections, such as for video games.
install packages with ./packages.sh
use gcc ddns.c https.c -o ddns -lcurl to compile.
To get started with config.ini rename config.example.ini to config.ini and change the values to suit you.
At the top of the file there should be Initialization configuration. The fields are:
interval How often to check if ip has changed in seconds.
throttle How long to wait between api calls when updating IP:s
clientId A name which is set to the comment field of controlled records.
After that configuration for the records. The fields are:
token Cloud flare api token.
zone The cloudflare hosting zone.
name The name of the record.
ipv4 The id of the record, if the record is ipv4
ipv6 The id of the record, if the record is ipv6
It is extremely important that token, zone and name have been defined before ipv4 or ipv6. The records use the last defined token, zone and name.
token has to be got from the cloudflare settings.
after that you can use the following commands repplacing [TOKEN] and [ZONE] as approppriate
get zone:
curl --request GET --url https://api.cloudflare.com/client/v4/zones/ --header "Authorization: Bearer [TOKEN]"
get record id
curl --request GET --url https://api.cloudflare.com/client/v4/zones/[ZONE]/dns_records/ --header "Authorization: Bearer [TOKEN]"