If you are hosting a Server on a local Raspberry Pi or want to connect to your Router with a VPN you probaply ran in to this issue before. Your external IP Adress changes one you reboot your Router or sometimes just once a day. To tackle this issue I created this tool.
It fetches the external IP from myexternalip.com and then saves it in a DNS record in your cloudflare account.
- Minimal Docker image (< 7 MB)
- Multiarch support (ARM64, ARMv7, ARMv6, x86, x64)
- One throw (Only executed once)
- Commandline support
- Fast and reliable
This container runs once, because often multiple runs are not needed.
I personally use it in Virtual Machines on GCP. Those are either preempted or restarted at least once a day. So there i no need for running a script periodically.
For a usecase have a look at Cloud Craft a cheap Minecraft Server that runs on GCP architecture
go get github.com/Herobone/cloudflare-ddns
For this tool a docker image is avaiable in the Docker Hub
Usage: cloudflare-ddns <flags> <subcommand> <subcommand args>
Subcommands:
update Update the DNS Record from public IP
The update command is the main used command. These are it's arguments and their corresponding Environment variables. If you want to parse the data via the variable you musn't set it's argument.
Environment variables are low priority and are overwritten. Arguments and variables can be mixed
-name string
The Name of the DNS Record (default "ddns")
This will be the name of the subdomain. The program will create a DNS record with this name
If not set the default content will be ddns
-proxied
Proxy IP over Cloudflare CDN
Should a regular record be created or a proxied record, that uses Cloudflare's CDN
If not given it's deactivated
-ttl int
Time To Live for the DNS record (default 120)
The Time to life for the DNS Record. Must be greater than 120 or bust be 1 to set "automatic"
If not set the default content will be 120 (seconds)
-zone string
Cloudflare Zone ID (Synonyms: -z)
The ID of the cloudflare Zone the record should be set up on.
Either this or -zoneName
is reuired. No need for both
-zoneName string
Cloudflare Zone name (i.e. 'example.com') (Synonyms: -zn)
The readable name of a cloudflare zone. Normally the domain it's set up on (i.e 'example.com')
Either this or -zone
is reuired. No need for both
Here are some examples on how to use the binary and the Docker image. These are not the only methods to start the program and are just for reference
cloudflare-ddns update -t YOUR_CLOUDFLARE_TOKEN_HERE -zn example.com -n web
This will create a DNS record at web.example.com
export CLOUDFLARE_API_TOKEN=your_cloudflare_token_here
export CLOUDFLARE_ZONE_ID=your_zone_id_here
cloudflare-ddns update
This will create a DNS record at ddns.yourdomain
docker run herobone/cloudflare-ddns update -t YOUR_CLOUDFLARE_TOKEN_HERE -zn example.com -n web
This will create a DNS record at web.example.com
export CLOUDFLARE_API_TOKEN=your_cloudflare_token_here
docker run -e CLOUDFLARE_API_TOKEN -e CLOUDFLARE_ZONE_ID=your_zone_id_here herobone/cloudflare-ddns update
This will create a DNS record at ddns.yourdomain