Giter Club home page Giter Club logo

ionos-dyndns's Introduction

ionos_dyndns.py

Create and update DNS records for a host using IONOS' API for use as a DynDNS (for example via a cronjob). The script will create A and/or AAAA records if none already exists for the host and update existing ones to reflect the new public IP.

The public IP-Address is determined in two ways:

  • IPv4: uses the ipify.org API
  • IPv6: uses the ip address show command

By default the name of the A/AAAA record that will be created/updated is one that matches the output from the command hostname -f.
Update your /etc/hosts file with your FQDN if it's not already there.
Alternatively you can override this default value by using the -H or --fqdn parameter.

Requirements

  • Linux
  • Python 3
  • IONOS API key

You can create an API key here: https://developer.hosting.ionos.de/keys
The API is still in Beta and not enabled by default. In my case I had to call the customer support hotline and request to be enabled for the API.

Usage

Cronjob

This example shows how to update the AAAA record every 5 minutes and save the script output to a file:

  1. Download the script and make sure it is executable
wget https://raw.githubusercontent.com/lazaroblanc/IONOS-DynDNS/main/ionos_dyndns.py
chmod +x ionos_dyndns.py
  1. Open your crontab file with crontab -e
  2. Paste this line:
*/5 * * * * ./ionos_dyndns.py --AAAA --api-prefix $publicprefix --api-secret $secret >> ionos_dyndns.log

General

usage: ionos_dyndns.py [-h] [-4] [-6] [-i] [-H] --api-prefix  --api-secret

Create and update DNS records for this host using IONOS' API to use as a sort of DynDNS (for example via a cronjob).

optional arguments:
  -h, --help         show this help message and exit
  -4, --A            Create/Update A record
  -6, --AAAA         Create/Update AAAA record
  -i , --interface   Interface name for determining the public IPv6 address (Default: eth0)
  -H , --fqdn        Host's FQDN (Default: hostname -f)
  --api-prefix       API key publicprefix
  --api-secret       API key secret

Ideas / To-do

  • improve log messages (add a timestamp)
  • refactor duplicate code (~ line 94)

๐Ÿ› Bug reports & Feature requests ๐Ÿ†•

If you've found a bug or want to request a new feature please open a new Issue

๐Ÿค Contributing

โœ… Pull requests are welcome!

๐Ÿ“ƒ License

Published under the Apache License 2.0
Please see the License for details

ionos-dyndns's People

Contributors

lazaroblanc avatar mricim avatar rhigginsde avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

ionos-dyndns's Issues

specify path to python in cronjob string?

Hi I am new to github and not even a programmer - a tinkerer really. First off - thank you very much for writing this python script! But I haven't been able to get it to work! :( I don't what I am doing, but I think maybe the string has to first specify to execute the script using python3 and include the path to python3 as well, right?
Should it look something rather like this?

*/15 * * * * /usr/bin/python3 ./ionos_dyndns.py --AAAA --api-prefix my_prefix_string --api-secret my_secret_string

Error when running script with -6/--AAAA when no public IPv6 address is configured

Origin: Trying get the first capture group from a regex match agains an empty string (because no public IPv6 address is configured)
Solution: Check if public IPv6 is configured on system and only then try to match the regex and get the output from the capture group. Otherwise just return an empty string and log a message saying no IPv6 address was found

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.