Skip to content

kshcherban/ddns-cloudflare

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ddns-cloudflare

Custom Dynamic DNS program to update Cloudflare DNS records with current external IP address.

How it works

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.

Installation

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):

  1. Add aarch64 target: rustup target add aarch64-unknown-linux-gnu
  2. Install aarch64 compiler and linker: sudo apt install gcc-aarch64-linux-gnu
  3. Update ~/.cargo/config with following lines:
    [target.aarch64-unknown-linux-gnu]
    linker = "aarch64-linux-gnu-gcc"
    
  4. Build: cargo build --target aarch64-unknown-linux-gnu --release

Usage

Create Cloudlare API token with zone edit permissions.

Export following environment variables:

  • API_TOKEN - Cloudflare API token
  • DOMAIN - subdomain that will be used to resolve external IP address, ie myip.example.com, where example.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.

About

Docker image for updating Cloudflare DNS records

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 95.8%
  • Dockerfile 4.2%