DEV Community

Cover image for Cloudflare as a Dynamic DNS🌩
Andrea Pavone
Andrea Pavone

Posted on

1 2

Cloudflare as a Dynamic DNS🌩

If you need to have a DNS record that point to a Dynamic IP (DDNS), for example, you home IP address, this tool allow you to accomplish this job!

For do this this we need cloudflare-dynamic-ip tool allow you to simply have a specific DNS record such as home.example.com that point to your dynamic IP.

Requirements

  • Domain Name
  • Cloudflare Account
  • Raspberry Pi4 or any other Linux Based OS
  • composer
  • php-7.3

Installation

Clone the Github repo, install dependencies, set API Token and set a cron job every 15min that run this script and you’re done!🚀

git clone https://github.com/andp97/cloudflare-dynamic-ip.git
cd cloudflare-dynamic-ip
INSTALL_PATH=$(pwd)
composer install --no-dev
nano .env
echo -e "*/15 * * * * $INSTALL_PATH/cf-ip 2>&1 > /dev/null\n"
crontab -e
Enter fullscreen mode Exit fullscreen mode

You can also execute this script via bash

#Get dns record name from env and target ip from remote host (https://ip.andreapavone.com) 

./cf-ip

#Passing parameters to the script

./cf-ip <dns_record_name> <target_ip>

Enter fullscreen mode Exit fullscreen mode

On .env file you can set:

Update

git pull
composer update
Enter fullscreen mode Exit fullscreen mode

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay