Custom Dynamic DNS program to update Cloudflare DNS records with current external IP address.
Program sends special DNS query to Cloudflare public DNS server in order to obtain computer's external IP address. Saves this address and updates specified Cloudflare DNS address if needed.
You need to install Rust in order to build this program. Please check this link.
Just run cargo build
to build a binary that can be found in target/debug/ddns-cloudflare
.
To cross-compile for aarch64 (Raspberry PI):
- Add aarch64 target:
rustup target add aarch64-unknown-linux-gnu
- Install aarch64 compiler and linker:
sudo apt install gcc-aarch64-linux-gnu
- Update
~/.cargo/config
with following lines:[target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc"
- Build:
cargo build --target aarch64-unknown-linux-gnu --release
Create Cloudlare API token with zone edit permissions.
Export following environment variables:
API_TOKEN
- Cloudflare API tokenDOMAIN
- subdomain that will be used to resolve external IP address, iemyip.example.com
, whereexample.com
is DNS zone managed by Cloudflare
By default program caches ipv4 address in file /tmp/cloudflare-ddns.txt
, if cached address matches current ipv4 external address then no action is performed, otherwise program creates/updates specified DOMAIN
DNS records with both ipv4 and ipv6 addresses.