A simple Rust script that checks your current public IP address and updates a Cloudflare A DNS record, working as a lightweight DDNS client.
Go to My Profile → API Tokens → Create Token in Cloudflare and use the Edit zone DNS template, restricting it to the zone (domain) you want to manage.
In the Cloudflare dashboard, open your domain page. The Zone ID is shown in the right sidebar under Overview.
cargo build --releaseThe binary will be generated at:
target/release/FarolYou can configure the script using environment variables:
export CF_API_TOKEN="your_token_here"
export CF_ZONE_ID="your_zone_id"
export CF_RECORD_NAME="home.yourdomain.com"
export CF_RECORD_TYPE="A"
export CF_PROXIED="false"
export CF_TTL="1"
./target/release/FarolOr use the equivalent command-line flags:
./target/release/Farol \
--api-token "your_token_here" \
--zone-id "your_zone_id" \
--record-name "home.yourdomain.com" \
--record-type A \
--ttl 1Use --proxied if you want the record to go through Cloudflare’s proxy (orange cloud). Without this flag, the record will remain DNS only.
You can run the script periodically with cron. For example, to check your IP every 15 minutes:
*/15 * * * * CF_API_TOKEN=xxx CF_ZONE_ID=xxx CF_RECORD_NAME=home.yourdomain.com /path/to/Farol >> /var/log/farol.log 2>&1The script only sends a PATCH request to Cloudflare when the IP has actually changed, so it is safe to run frequently.
- Queries
https://api.ipify.org/https://4.icanhazip.comto determine the current public IP address. - Checks Cloudflare for an existing DNS record matching the configured name and type.
- If the record exists and already points to the current IP, nothing is changed.
- If the record exists but is outdated, it is updated with a
PATCHrequest.