Elephlink

Elephlink

A powerful, lightweight Dynamic DNS client that uses the Cloudflare API to keep your domain name pointing to your home network.

It allows you to reliably access self-hosted services (like a NAS, media server, or smart home hub) via a custom domain, even when your Internet Service Provider assigns you a dynamic IP address.

  • Cost-Effective: No need to pay your ISP for a static IP address.
  • Effortless: Runs on a schedule to automatically detect IP changes and update your DNS records in seconds.
  • Flexible: Supports multiple domains, configurable IP detection services and cron-based scheduling.
  • Secure: Works with modern Cloudflare API tokens for granular, secure access.
  • Footprint: Low footprint on your system.

๐Ÿš€ Features

  • Seamless integration with the Cloudflare v4 API.
  • Supports multiple DNS records across different domains.
  • Periodic IP checking with cron-based scheduling.
  • Pluggable IP detection services using a configurable list of providers.
  • All configuration is external, making it perfect for containerized deployments.

โš™๏ธ How it Works

  1. IP Detection: Regularly checks your public IP using one or more external services (at your choice).
  2. Cloudflare Validation: Authenticates with Cloudflare and verifies your DNS records.
  3. DNS Update: If your public IP changes, automatically updates the specified Cloudflare DNS records.
  4. Scheduling: Runs on a user-defined schedule (e.g. every few minutes) using cron expressions.

๐Ÿƒ Getting Started

Prerequisites

TypeNameContentProxy statusTTL
Adomain.com1.1.1.1ProxiedAuto

Running on Docker

  1. Running in Docker
docker run \
  --name elephlink \
  --restart unless-stopped \
  -v /path/to/config/dir/:/config \
  -e JAVA_OPTS=-Xmx15m \
  roomelephant/elephlink:latest

or

services:
  elephlink:
    image: roomelephant/elephlink:latest
    volumes:
      - /path/to/config/dir/cloudflare.yml:/config/cloudflare.yml
      - /path/to/config/dir/ip-services.yml:/config/ip-services.yml
      - /path/to/config/dir/dns-records.yml:/config/dns-records.yml
  1. Configuration

The application will validate your configuration, verify the DNS records in Cloudflare and start the update schedule.

Create three YAML configuration files. You can start by copying the examples from src/main/resources/.

cloudflare.yml: This file handles your Cloudflare API credentials.

# The email associated with your Cloudflare account.
email: user@example.com
# Your Cloudflare API token or Global API key.
key: YOUR_CLOUDFLARE_API_TOKEN
# The Zone Identifier for your domain, found on the "Overview" page in the Cloudflare dashboard.
zoneIdentifier: YOUR_ZONE_ID

dns-records.yml: This file defines which DNS records to update and how often.

# A list of DNS records you want ElephLink to manage.
records:
  - subdomain.yourdomain.com
  - another.yourdomain.com
# UNIX Cron Expression for the update schedule.
# This example runs every day at 04:00 AM
cron-expression: "0 4 * * *"
# Timeout for requesting and updating dns records
timeout-in-milliseconds: 3000 # default 1000 milliseconds

A quick guide to cron expressions:

 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ minute (0 - 59)
 โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ hour (0 - 23)
 โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ day of month (1 - 31)
 โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ month (1 - 12 or JAN-DEC)
 โ”‚ โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ day of week (0 - 6 or SUN-SAT, 0 = Sunday)
 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
 โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
 * * * * *

ip-services.yml: A list of web services that return your public IP address as plain text. ElephLink will try them in order until one succeeds.

# A list of plaintext IP reflector services.
services:
  - https://api.ipify.org
  - https://icanhazip.com
  - https://ipinfo.io/ip
# Timeout for requesting external ip
timeout-in-milliseconds: 1000 # default 1000 milliseconds

Running Java

  1. Download jar

Download jar from the release notes: https://github.com/Room-Elephant/ElephLink/releases

wget https://github.com/Room-Elephant/ElephLink/releases/download/v1.0.1/elephlink-1.0.1.jar
  1. Run the Application

Requires Java 21 or higher.

java -jar elephlink-1.0.1.jar \
   --cloudflare-file=path/to/cloudflare.yaml \
   --dns-records-file=path/to/dns-records.yaml \
   --ip-service-file=path/to/ip-services.yaml

If your configuration files are in the same directory as the JAR, you can omit the arguments:

java -jar elephlink-1.0.1.jar

Build locally

  1. Build from Source
git clone https://github.com/Room-Elephant/ElephLink.git
cd ElephLink
mvn clean install
  1. Run java application

Use IntelliJ configuration .run/Main.run.xml to run locally. Or use the configuration provided above.

  1. Build the Docker image
docker build -t elephlink .
  1. Run the container Place your configuration files (cloudflare.yaml, dns-records.yaml, ip-services.yaml) in a single directory (e.g., ./config). Then, run the container with that directory mounted as a volume.
docker run --name elephlink \
  -v $(pwd)/src/main/resources:/config \
  --restart always \
  -e JAVA_OPTS=-Xmx15m -XX:+UseSerialGC \
  elephlink

Troubleshooting

You can use -Dlog.level=DEBUG to activate debugging logs. On docker, you can use the env variable JAVA_OPTS to pass the logging level.

๐Ÿค Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

๐Ÿ™‡โ€โ™‚๏ธ Acknowledgments

This project was inspired by the functionality of the K0p1-Git/cloudflare-ddns-updater bash script.

License

This project is licensed under the MIT License. See the LICENSE file for details.