Script to update DNS records using the spaceship API
Project description
Tool for updating DNS records for domains hosted by https://www.spaceship.com/.
This tool utilizes https://github.com/bwiessneth/spaceship-api.
The script will detect your system’s external IPv4 and/or IPv6 addresses and update the configured DNS records using your Spaceship API credentials.
Installation
pip install spaceship-dns-updater
Usage
Call spaceship-dns-updater from the directory where your config file is placed.
If you have several config files, specify the one you want:
spaceship-dns-updater --config <PATH_TO_YOUR_CONFIG_FILE>
Logs
When running on Windows, the log files are located in:
%LOCALAPPDATA%\spaceship-dns-updater\logs (e.g., C:\Users\YOUR_NAME\AppData\Local\spaceship-dns-updater\logs)
When using Linux/macOS, the log files are written to:
~/.local/state/spaceship-dns-updater/logs
These log files rotate automatically if they exceed 1 MB in size and are retained for up to 30 days.
🕒 Run Automatically with systemd (Linux only)
To run spaceship-dns-updater on a schedule (e.g., every 15 minutes), you can create a user-level systemd timer.
Create the following two files in ~/.config/systemd/user/:
# spaceship-dns-updater.service
[Unit]
Description=Spaceship DNS Updater
[Service]
Type=oneshot
ExecStart=/usr/bin/python3 /home/YOUR_NAME/spaceship-dns-updater/spaceship_dns_updater.py
WorkingDirectory=/home/YOUR_NAME/spaceship-dns-updater
StandardOutput=append:%h/.local/state/spaceship-dns-updater/logs/systemd-output.log
StandardError=append:%h/.local/state/spaceship-dns-updater/logs/systemd-error.log
# spaceship-dns-updater.timer
[Unit]
Description=Run Spaceship DNS Updater every 15 minutes
[Timer]
OnBootSec=5min
OnUnitActiveSec=5min
Persistent=true
[Install]
WantedBy=timers.target
Then enable and start the timer:
systemctl --user daemon-reload
systemctl --user enable --now spaceship-dns-updater.timer
Check status or logs with:
systemctl --user status spaceship-dns-updater.timer
journalctl --user -u spaceship-dns-updater.service
Configuration
Basic Configuration
Create a YAML config file with your domain name, API credentials, and details about the DNS record you want to update.
The most basic config looks like this:
your-domain.com:
api_key: <YOUR_API_KEY>
api_secret: <YOUR_API_SECRET>
records:
- type: "A"
name: "@"
ttl: 1800
Records
For each record you want to update, add it to the list of records:
records:
- type: "A"
name: "@"
ttl: 1800
- type: "AAAA"
name: "@"
ttl: 1800
- type: "A"
name: "subdomain"
ttl: 1800
For records of type A, the IPv4 address obtained from https://www.ipify.org/ will be used. If no IPv4 address is found, the record will be skipped.
Similarly, for records of type AAAA, the IPv6 address retrieved from https://www.ipify.org/ will be used. If no IPv6 address is available, the record will be skipped.
Multiple domains
If you are owner of multiple domains you can add them to the same YAML config file.
your-first-domain.com:
api_key: <YOUR_API_KEY>
api_secret: <YOUR_API_SECRET>
records:
- type: "A"
name: "@"
ttl: 1800
your-second-domain.com:
api_key: <YOUR_API_KEY>
api_secret: <YOUR_API_SECRET>
records:
- type: "A"
name: "@"
ttl: 1800
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spaceship_dns_updater-0.1.0.tar.gz.
File metadata
- Download URL: spaceship_dns_updater-0.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.1 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5330e54dbc430513d7d86eb838cd2f16a19d3afac7aa8a32eb8c39c4e4128b61
|
|
| MD5 |
34d33cc7f4db8124bfe217c0f283b0a6
|
|
| BLAKE2b-256 |
1ad3a92983fa000abbe15f3960c434016ac62cf0b10a0c6e5e92f5a2a9b77d19
|
File details
Details for the file spaceship_dns_updater-0.1.0-py3-none-any.whl.
File metadata
- Download URL: spaceship_dns_updater-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.1 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e90f58a0d1b5081626c879d553ebdbff5a5ac84134bd3e83228dc934c1392837
|
|
| MD5 |
96a9834450285cd5a6900fd53df95bac
|
|
| BLAKE2b-256 |
37570ddcd6411c3b705a4061e9a30c00ef395053b5879a46d9ff0ba59bdd9aab
|