Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/danamir/dyn-gandi

Use Gandi LiveDNS API to update DNS records with a dynamic IP.
https://github.com/danamir/dyn-gandi

dns dynamic gandi ip livedns restful-api

Last synced: about 2 months ago
JSON representation

Use Gandi LiveDNS API to update DNS records with a dynamic IP.

Awesome Lists containing this project

README

        

# dyn-gandi
Use Gandi LiveDNS API to update DNS records with a dynamic IP.

#### Prequisites

- Generate a Gandi Personal Access Token (PAT) via either https://account.gandi.net/en/users/USER/security (where USER is your username), or Gandi Dashboard > Organizations > Manage > Create a token :
- Choose a mandatory duration (Gandi allows one year max)
- Give access at least to the resource `DNS configuration`
- Python 3.x

##### Note

I recommend creating a repeating alarm in a calendar to be sure to renew the PAT before it is revoked.

#### Installation

##### Installation from release :
- Download and extract the latest [release](https://github.com/Danamir/dyn-gandi/releases).
- Open a terminal to the extracted directory.

##### Installation from sources :
```shell
$ curl --location https://github.com/Danamir/dyn-gandi/archive/master.zip --output dyn-gandi-master.zip
$ unzip dyn-gandi-master.zip
$ mv dyn-gandi-master/ dyn-gandi
$ cd dyn-gandi
```

##### Setup :
_(Optional)_ Configure Python virtual environment :
```shell
$ python -m venv .env
$ . .env/bin/activate (Linux)
-or-
$ .env\Scripts\activate.bat (Windows)
```

Install :
```shell
$ python setup.py develop
$ copy config.ini-dist config.ini
$ dyn_gandi --help
-or-
$ python dyn_gandi.py --help
```

Complete the `config.ini` file, in particular check the lines :
```ini
[api]
key =

[dns]
domain =
records = @,www
```

#### Running
_Note: `dyn_gandi` can be substituted with `python dyn_gandi.py` if the former doesn't work._

Display help :
```shell
$ dyn_gandi --help
```

Dry run (without modifications) :
```shell
$ dyn_gandi --dry-run
```

Normal launch:
```shell
$ dyn_gandi
```

The log line will end by `[OK]` if no update was needed, `[UPDATE]` on successful update, and `[ERROR]` on error.
On success, the automatic backup snapshot is deleted ; on error the snapshot uuid is displayed in the log
for you to restore if needed.

#### Cron
Either create a scheduled task on windows, or add a crontab line. ie:
```shell
$ crontab -e
* */2 * * * dyn_gandi --log /var/log/dyn-gandi.log
```

NB: If you used a Python virtual environment, replace the script by `/.env/bin/dyn_gandi` .

###### Notes
- [Gandi LiveDNS documentation](https://api.gandi.net/docs/livedns/)
- Thanks [Gandyn](https://github.com/Chralu/gandyn) for the inspiration (and many years of use)

###### Common errors
- Ensure that your domain is correctly handled by Gandi LiveDNS API by following [this guide](https://docs.gandi.net/en/domain_names/common_operations/changing_nameservers.html#switching-to-livedns).