Schedule icon
Webhook icon
Request icon
Get icon
If icon
Set icon
SlackIncomingWebhook icon

Dynamic IP Monitor with Automated Cloudflare DNS Updates

Fetch your public IP, compare it with the last value in the KV store, and automatically update Cloudflare DNS records on change.

Categories
Infrastructure

Home labs, VPNs and NAT gateways change their public IP without telling you, and then allow-lists and firewall rules quietly stop matching. This blueprint checks the egress IP, remembers it, and automatically updates your Cloudflare DNS A record the moment it changes, notifying your team via Slack.

How it works

  1. get_current_ip (io.kestra.plugin.core.http.Request) asks an IP service for the address your worker's traffic comes from.
  2. get_previous_ip (io.kestra.plugin.core.kv.Get) loads the IP saved by the previous run. Missing on the very first run, which is fine.
  3. check_ip_change (io.kestra.plugin.core.flow.If) evaluates if the current IP differs from the stored IP.
  4. If changed, it fans out to update_cloudflare_dns (PUT request to Cloudflare API), save_new_ip (updates the KV store), and notify_slack.
  5. If unchanged, the flow gracefully exits without making unnecessary API calls or sending spammy notifications.
  6. Triggers: a Schedule every hour and a Webhook for on-demand checks.

What you get

  • A saved record of the last known egress IP in the KV store.
  • Automated Cloudflare DNS A record updates only when the IP actually changes.
  • Instant Slack notifications detailing the old and new IP addresses.
  • Robust error handling via the errors block to catch API or network failures.

Who it's for

  • Home-lab and self-hosting users on a dynamic residential IP.
  • DevOps and SRE teams managing remote servers, VPNs, or NAT gateways.
  • Anyone who needs to keep allow-lists or firewall rules synchronized with a changing egress IP.

Why orchestrate this with Kestra

A simple cron script can check an IP, but it cannot remember state between runs, prevent API rate limits by skipping unchanged IPs, or provide a centralized, observable execution history. Kestra supplies the durable KV store for state tracking, declarative YAML for the branching logic, built-in scheduling, and seamless integration with notification plugins.

Prerequisites

  • A Cloudflare account with a managed domain.
  • The Kestra worker needs outbound HTTPS access to api.ipify.org and api.cloudflare.com.

Secrets

  • CF_ZONE_ID: Your Cloudflare Zone ID (found in the domain overview).
  • CF_API_TOKEN: Cloudflare API token with Zone:DNS:Edit permissions.
  • SLACK_WEBHOOK_URL: Slack incoming webhook URL for notifications.

Inputs

  • domain_name (STRING, default home.example.com): The domain to update.
  • cloudflare_zone_id (STRING): Your Cloudflare Zone ID.
  • cloudflare_api_token (STRING): Cloudflare API token.
  • slack_webhook_url (STRING): Slack webhook URL.

Quick start

  1. Add the required secrets (CF_ZONE_ID, CF_API_TOKEN, SLACK_WEBHOOK_URL) to your Kestra namespace.
  2. Save the flow and click Execute. The first run will fetch the IP, store it in the KV store, and update Cloudflare.
  3. Execute again. It should detect no change and gracefully exit without hitting the Cloudflare API or sending a Slack message.
  4. To simulate a change, manually edit the KV store value for the IP to a different address, then run the flow again to see the update and Slack alert trigger.
  5. Enable the hourly_check trigger when you are happy.

Example outputs

  • outputs.get_current_ip.body: 203.0.113.7
  • outputs.get_previous_ip.value: 198.51.100.42

How to extend

  • Replace the Slack notification with an email, PagerDuty, or Opsgenie alert for critical infrastructure.
  • Add a secondary check to verify SSL certificate validity on the same domain.
  • Log every IP change to a database (e.g., Postgres or DuckDB) for historical auditing and SLA reporting.
  • Add support for updating multiple DNS records (e.g., both @ and www subdomains) in a single run.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.