Coder Social home page Coder Social logo

geekwolverine / cloudflare-dynamic-dns Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nickian/cloudflare-dynamic-dns

0.0 1.0 0.0 12 KB

A PHP script that checks for changes to your public IP and updates a Cloudflare "A" record with your new IP address when it detects a change.

License: MIT License

PHP 100.00%

cloudflare-dynamic-dns's Introduction

Cloudflare Dynamic DNS

A PHP script that checks for changes to your public IP and updates a Cloudflare "A" record with your new IP address when it detects a change.

Setup

Install Dependencies

You should have Composer installed.

composer install

Create a Token

Create an API token: https://dash.cloudflare.com/profile/api-tokens

Create an API token with permissions to edit DNS records for the zone you wish to use.

Copy and Update the config.template.php File.

cp config.template.php config.php

Add your TOKEN value and add SMTP info, if you want to enable email notifications about IP changes.

Run the Script

php cli.php

Run the script yourself from the command line the first time. You will be prompted to define the zone name and record name. The script will obtain your current public IP and get the zone and record IDs. If a record does not exist with the name you provided, one will be created.

Each time script runs again, it will obtain your current public IP and compare it with the last value saved in the JSON file. If it detects a change, it will update the DNS record.

Add a recurring cron job

Add the script to a cron job to automatically check for IP changes at a given interval.

Edit cron jobs for current user: crontab -e

or for a specific user sudo crontab -u user -e

Paste and edit the line below to suit your needs. This runs the script every hour and stores the output in the log file in the same directory.

0 */1 * * * /usr/bin/php -f /path/to/Cloudflare-Dynamic-DNS/cli.php > /path/to/Cloudflare-Dynamic-DNS/log

cloudflare-dynamic-dns's People

Contributors

nickian avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.