Sign inSign up

jtmb92/cloudflare_ip_checker

By jtmb92

โ€ขUpdated over 2 years ago

Image
0

1.4K

jtmb92/cloudflare_ip_checker repository overview

โ  Logo โ 

Cloudflare IP Checker - Keep your cloudflare proxy records automatically updated!

Report a Bugโ  ยท Request a Featureโ  . GitHubโ 

โ About

An Alpine-based microservice within Docker, designed to seamlessly manage and update Cloudflare records whenever a change is detected in your publicly-facing IP address.

This solution proves invaluable for those who self-host using a dynamic IP address, ensuring the uninterrupted integrity of their Cloudflare DNS records.

โ Highlighted Features:
  • Streamlined addition of monitored A records in cases of accidental removal.
  • Automatic identification of changes in the forward-facing IP facilitating the prompt update of A records with the new IP address.
  • User-friendly customization achieved through a concise set of environment variables.
  • Integration with Discord for simple alert notifications.
  • Fast - API request total time on average is less than a second.
  • Lightweight - Alpine Container keeps the image size below 15 MB.
  • Scalable - Built with scale in mind, Docker Swarm compatible.
โ Example:

Example

โ Discord Alerting:

Discord

โ Prerequisites

  • Docker installed on your system
  • A Discord webhook URL
  • A Cloudflare API Key
  • The ZONE ID for your Cloudflare instance
โ 

โ Getting Started

โ Docker Imageโ 
 docker pull jtmb92/cloudflare-ip-checker
โ Running on docker

A simple docker run command gets your instance running.

    docker run --name ip-checker-container \
    -e EMAIL="[email protected]" \
    -e API_KEY="your-cloudflare-api-key" \
    -e ZONE_ID="your-cloudflare-zone-id" \
    -e WEBHOOK_URL="your-discord-webhook-url" \
    -e DNS_RECORDS="my.site.com/A site.com/A" \
    -e REQUEST_TIME=120 \
    jtmb92/cloudflare-ip-checker
โ Running on docker-compose

Run on Docker Compose (this is the recommended way) by running the command "docker compose up -d".

    version: '3.8'

    services:
    ip-checker:
        image: jtmb92/cloudflare-ip-checker
        environment:
          EMAIL: '[email protected]'
          API_KEY: 'your-cloudflare-api-key'
          ZONE_ID: 'your-cloudflare-zone-id'
          WEBHOOK_URL: 'your-discord-webhook-url'
          DNS_RECORDS: 'my.site.com/A site.com/A'
          REQUEST_TIME: '2m'
โ Running on docker-compose with custom dockerfile

Similar to the above example, the key difference here is that we are running with the build: argument instead of the image: argument. The . essentially builds the Docker image from a local Dockerfile located in the root directory where the docker compose up -d command was run.

    version: '3.8'

    services:
    ip-checker:
        build: .
        environment:
          EMAIL: '[email protected]'
          API_KEY: 'your-cloudflare-api-key'
          ZONE_ID: 'your-cloudflare-zone-id'
          WEBHOOK_URL: 'your-discord-webhook-url'
          DNS_RECORDS: 'my.site.com/A site.com/A'
          REQUEST_TIME: '120'
โ Running on swarm

Meant for advanced users Here's an example using the Loki driver to ingress logging over a custom Docker network while securely passing in ENV vars.

    version: "3.8"
    services:
    cloudflare-ip-checker:
        image: "jtmb92/cloudflare_ip_checker"
        restart: always
        networks:
            - container-swarm-network
        environment:
            API_KEY:  ${cf_key}
            ZONE_ID: ${cf_zone_id}
            WEBHOOK_URL: ${discord_webook}
            DNS_RECORDS: 'my.site.com/A site.com/A'
            REQUEST_TIME: "5m"
            EMAIL: ${email}
        deploy:
        replicas: 1
        placement:
            max_replicas_per_node: 1
        logging:
        driver: loki
        options:
            loki-url: "http://localhost:3100/loki/api/v1/push"
            loki-retries: "5"
            loki-batch-size: "400"
    networks:
    container-swarm-network:
        external: true

jtmb92/cloudflare_ip_checker

โ Environment Variables explained

    EMAIL: '[email protected]'

Your Cloudflare account email address. This is used to authenticate with the Cloudflare API.

    API_KEY: 'your-cloudflare-api-key'

Your Cloudflare API key. This key is required for making authenticated requests to the Cloudflare API.

    ZONE_ID: 'your-cloudflare-zome-id'

The ID of the Cloudflare DNS zone where your records are managed. This identifies the specific zone to update.

    WEBHOOK_URL: 'https://discord.com/api/webhooks/<redacted>/<redacted>'

The URL of your Discord webhook. This is where notifications will be sent when IP changes are detected.

    DNS_RECORDS: 'my.site.com/A site.com/A' #example of multiple list format entries

A space-separated list of Cloudflare DNS records in the format "name/type". These records will be checked and updated if necessary.

    REQUEST_TIME: '10' #amount of time in seconds between next set of API requests. 
    REQUEST_TIME: '2m'  #amount of time in minutes between next set of API requests. 
    REQUEST_TIME: '1h'  #amount of time in hours between next set of API requests. 
    REQUEST_TIME: '1d'  #amount of time in days between next set of API requests. 

The time to wait between IP checks. This determines the interval at which the script checks for IP changes.

  • ** Make sure to provide the appropriate values for these variables when running the Docker container. This information is crucial for the script to function correctly.

Tag summary

Content type

Image

Digest

sha256:327389e94โ€ฆ

Size

53.1 MB

Last updated

over 2 years ago

docker pull jtmb92/cloudflare_ip_checker