Code Monkey home page Code Monkey logo

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.

Configure

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"
...

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: 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://www.driescode.dev/d2c.sh)

$ crontab -e # set cronjob to run periodically

d2c.sh's People

Contributors

ddries avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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