Skip to content

Herobone/Cloudflare-DDNS

Repository files navigation

Docker Image Size (latest by date) Docker Pulls GitHub release (latest by date) GitHub Workflow Status

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.

Key features

  • 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

Install module

go get github.com/Herobone/cloudflare-ddns

Docker Container

For this tool a docker image is avaiable in the Docker Hub

Usage

Usage: cloudflare-ddns <flags> <subcommand> <subcommand args>

Subcommands:
        update           Update the DNS Record from public IP

update

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

  -name string
        The Name of the DNS Record (default "ddns")
Description

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

Synonyms -n string
Environment Variables: DDNS_NAME

proxied

  -proxied
        Proxy IP over Cloudflare CDN
Description

Should a regular record be created or a proxied record, that uses Cloudflare's CDN

If not given it's deactivated

Synonyms -p
Environment Variables: DDNS_PROXIED

ttl

  -ttl int
        Time To Live for the DNS record (default 120)
Description

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)

Environment Variables: DDNS_TTL

zone

  -zone string
        Cloudflare Zone ID (Synonyms: -z)
Description

The ID of the cloudflare Zone the record should be set up on.

Either this or -zoneName is reuired. No need for both

Synonyms -z
Environment Variables: CLOUDFLARE_ZONE_ID

zoneName

  -zoneName string
        Cloudflare Zone name (i.e. 'example.com') (Synonyms: -zn)
Description

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

Synonyms -zn
Environment Variables: CLOUDFLARE_ZONE_NAME

Usage Examples

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

Binary

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

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published