Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spaceship_dns_updater-0.0.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spaceship_dns_updater-0.0.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file spaceship_dns_updater-0.0.0.tar.gz.

File metadata

  • Download URL: spaceship_dns_updater-0.0.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

Hashes for spaceship_dns_updater-0.0.0.tar.gz
Algorithm Hash digest
SHA256 d0f0e4d982646049146e86cc84f9abb894effbf521814c4f7241c9ea06c9ae8c
MD5 00782a93874625c1b5543bfed8f3b21c
BLAKE2b-256 92f93c6dff57e4f3262700e905c0ebe7d4e64702ce5adddd4ac37c7d7121986f

See more details on using hashes here.

File details

Details for the file spaceship_dns_updater-0.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for spaceship_dns_updater-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 52f921caf6cdf14ac42c4fb667f3ffe5194b6c07de2ca70a7bb245b1621baa24
MD5 29c07c2c44400c2aef0331356e4e8609
BLAKE2b-256 fe11ec50cceb0cc365fa37ed6537c0ddefe208faf0c114c4e7a88dd946901822

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page