GithubHelp home page GithubHelp logo

steeven9 / d2c.sh Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ddries/d2c.sh

0.0 0.0 0.0 27 KB

Update Cloudflare DNS 'A' records for your dynamic IP.

License: GNU General Public License v3.0

Shell 96.27% Dockerfile 3.73%

d2c.sh's Introduction

d2c.sh

Update Cloudflare DNS 'A' records for your dynamic IP.

d2c.sh (Dynamic DNS Cloudflare) is a very simple bash script to automatically update the IP address of A DNS records from Cloudflare.

Configuration

d2c.sh is configured using a TOML file located in /etc/d2c/d2c.toml. The first time you run d2c.sh from the command-line, it will create the config directory for you. You still have to manually create the TOML configuration file.

Syntax:

[api]
zone-id = "aaa" # your dns zone id
api-key = "bbb" # your api key with dns records permissions

[[dns]]
name = "dns1.example.com" # dns name
proxy = true # proxied by cloudflare?

[[dns]]
name = "dns2.example.com"
proxy = false

When d2c.sh is ran, it UPDATES the records configured in /etc/d2c/d2c.toml with the current public IP of the machine. The A records be created from the Cloudflare dashboard, then d2c.sh will be able to UPDATE them with the public IP of the server.

Usage

$ d2c.sh --help

d2c (Dynamic Dns Cloudflare): Update the Cloudflare DNS A records for your dynamic IP.

Usage: d2c.sh

`d2c` UPDATES existing records. Please, create them in Cloudflare Dashboard before running this script.

The configuration is done in `/etc/d2c/d2c.toml` in TOML format.
Configuration file structure:

[api]
zone-id = "<zone id>"
api-key = "<api key>"

[[dns]]
name = "test.example.com"
proxy = false

[[dns]]
name = "test2.example.com"
proxy = true

Method 1: Installing d2c.sh

Install d2c.sh using the installation script:

$ ./install

Successfully installed d2c.sh into /usr/local/bin.
Please, run d2c.sh from command-line before scheduling any cronjob.
Help: `d2c.sh --help` or `d2c.sh -h` or `d2c.sh help`.

Then, run d2c.sh from command-line for the first time:

$ d2c.sh

Directory: /etc/d2c/ does not exist.
Creating...
Created /etc/d2c/. Please, fill /etc/d2c/d2c.toml.

Fill /etc/d2c/d2c.toml with your zone id, API key and the desired DNS':

$ sudo nano /etc/d2c/d2c.toml

[api]
zone-id = "aaa"
api-key = "bbb"
...

(see d2c_example.toml for the syntax)

Finally, you can run manually d2c.sh or set up a cronjob to update periodically:

$ d2c.sh # manually

[d2c.sh] OK: dns1.example.com
[d2c.sh] OK: dns2.example.com

$ crontab -e # set cronjob to run d2c.sh periodically

Method 2: Docker

See docker-compose.yml for an example config.

Note: you will need to find a way to run it periodically (e.g. swarm-cronjob in Swarm mode).

Method 3: Executing from URL

You can also execute d2c.sh avoiding the installation. Note that you must still have a valid configuration file: /etc/d2c/d2c.toml.

Execute from URL:

$ bash <(curl -s https://raw.githubusercontent.com/ddries/d2c.sh/master/d2c.sh)

[d2c.sh] OK: dns1.example.com
[d2c.sh] OK: dns2.example.com

To run periodically without installing, you can write your own script:

$ nano run_d2c.sh

#!/bin/bash
bash <(curl -s https://raw.githubusercontent.com/ddries/d2c.sh/master/d2c.sh)

$ crontab -e # set cronjob to run periodically

Notifications

If the APPRISE_SIDECAR_URL environment variable is set, a notification will be sent out to the specified Apprise container when a record is updated or if a failure is encountered.

d2c.sh's People

Contributors

ddries avatar steeven9 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.