| systemd | ||
| .flake8 | ||
| .gitignore | ||
| config.py | ||
| LICENSE | ||
| lint.sh | ||
| logger.py | ||
| Makefile | ||
| pyproject.toml | ||
| README.md | ||
| requirements-dev.txt | ||
| requirements.txt | ||
| sample-config.yml | ||
| update.py | ||
loopia-dynamic-dns
DNS update script for loopia.se. Allows automatic update of a DNS record directly from a server, pc etc.
Installation
You can install this to /opt/loopia-dynamic-dns using make install.
There is also a PKGBUILD for Arch Linux at arch/loopia-dynamic-dns-git.
In the systemd folder, you can find example systemd configuration files that work with the install from the Makefile.
This enables a 1-minute timer for systemd to regularly run the update scripts.
Usage
Usage: python update.py [CONFIG_FILE]
If not specified, CONFIG_FILE defaults to config.yml in the working directory.
Setup
For anyone with some python experience this should be straight forward:
Dependencies
- requests
- pyyaml
Needed softwares
- python3.x
Step by step
- Clone the repo or get the script files to your hard drive in some other way
- Install pre-requisite packages locally or in your virtual environment
pip install -r requirements.txt
- Make a copy of sampleconfig.yml and name it config.yml
cp sample-config.yml config.yml
- Configure config.yml with your settings (see configuration section)
- Run script update.py
python3 update.py
CONFIGURATION
The script in its current form uses a yaml file for housing configuration. A sample config has been provided and can be used as a base for your settings.
Note! You have to create an API user in loopias "Kundzon" with atleast the following 4 privileges set:
- getZoneRecords
- addZoneRecords
- updateZoneRecord
- removeZoneRecord
To update the base domain, simply put '@' as the subdomain, just as you would in any bind9 zone file.
Logging
Logging is supported in the application. As of now both file logging and stream logging (console) is added and can be enabled by configuration.
log_level_console: 10
log_level_file: 0
log_file: application.log
Log levels
| Log level | Value |
|---|---|
| Disabled | 0 |
| DEBUG | 10 |
| INFO | 20 |
| WARNING | 30 |
| ERROR | 40 |
| CRITICAL | 50 |
Setting a value to one of these numbers means you will see that level and all levels of a higher number in the console output. Example that will show Information, Warning, Error and Critical log messages:
log_level_console: 20
Configuration
The script will be looking for the file config.yml for its' settings if no other filepath was specified.
Copy or rename the sample-config.yml to config.yml and update with your own settings.