**Snap DynDNS Server** is a tiny Dynamic DNS service for domains managed by the registrar InterNetworX (inwx.de). It is a single Python file without dependencies beyond the standard library, made to run as a small service on shared hosting such as Uberspace.
The server is a credential broker: your INWX API login only exists on the server, while each device gets its own random token that can update exactly one hostname. A device that gets lost or compromised can be cut off by deleting one section from the config.
It speaks the common dyndns2 protocol (HTTP Basic Auth, `myip`/`myipv6`, `good`/`nochg` answers) on `/nic/update`, so routers like the AVM FritzBox, ddclient, and plain `curl` work. The matching client is [Snap DynDNS client](https://src.mehl.mx/mxmehl/snap-dyndns-client), a small shell script for cron.
2. The server compares the SHA-256 of the token with the config.
3. If the IP equals the last one it stored, it answers `nochg` right away. INWX is not contacted, so polling every minute is cheap.
4. Otherwise it logs in to INWX, looks up the record by name and type, updates it, and only then stores the new IP. If INWX fails, the device gets `911` and retries on its next run.
The record (A and/or AAAA) has to exist at INWX already. The server picks A or AAAA depending on the IP family, and keeps the TTL you set there. The connection to INWX uses IPv4 only, so an IP-restricted INWX API account only needs the server's IPv4 address on its allow-list.
- A way to run a service behind HTTPS, e.g. supervisord plus a reverse proxy (Uberspace has both)
- An INWX account or API sub-account. If 2FA is enabled, the TOTP shared secret is needed as well. IP-restricted API accounts work if the server's IPv4 address is allowed.
The server speaks plain HTTP and expects a reverse proxy in front that terminates TLS. Never expose it without HTTPS, as the token is sent with every request.
If your Python is not at `/usr/bin/python3.14`, adjust the path. Start the service and register it as a web backend for the `/nic` path of your domain:
Check with `supervisorctl status` and `uberspace web backend list`. Errors and requests are logged to `~/logs/` (or `supervisorctl tail snap-dyndns stderr`).
The service also answers `/` with a short start page, but with the backend registered for `/nic` only `/nic` and `/nic/` reach it. To show the page on the domain's root as well, register the whole domain instead: `uberspace web backend set yourdyndnsservice.net --http --port 8080`.
Behind the reverse proxy the TCP peer is the proxy, not the device. On Uberspace the proxy puts the device's address into `X-Forwarded-For`, which is already set in `config.toml.sample`:
The server uses the last entry of that header, the one added by your own proxy. Entries before it are controlled by the client and ignored. If the header is missing, or the address is not a global one, the answer is `badip` and a log line instead of a wrong DNS record. Check once that the `good <ip>` answer shows your real public IP.
With another proxy, stop the service (`supervisorctl stop snap-dyndns`), run `nc -l 8080` and open the URL once from outside. `nc` prints the raw request including all headers, so you can see in which one your public IP appears.
### Adding a device
The helper creates a random token, stores only its SHA-256 in the config and prints the token once:
Give the printed token to the device, for the [client](https://src.mehl.mx/mxmehl/snap-dyndns-client) it is the `hostname:token` entry shown in the output. For an existing host it asks before replacing the token (`-y` skips the question), and the old token stops working immediately. Use `-c` for a config in another location and `-z example.co.uk` for a new host whose INWX zone is not the last two labels of its name. Comments and the rest of the config stay untouched. The config is read on every request, so no restart is needed.
The hostname is the Basic Auth user name, the token the password. Without the helper, generate a token and hash yourself with `python3 -c 'import secrets,hashlib;t=secrets.token_urlsafe(32);print(t, hashlib.sha256(t.encode()).hexdigest())'` and add a section `[hosts."user1.example.com"]` with `token_sha256 = "<hash>"`.
The tests use a fake INWX server. An additional smoke test runs against the INWX OT&E test system and is skipped unless `INWX_OTE_USER`, `INWX_OTE_PASS` and `INWX_OTE_HOST` (an existing A record in that account) are set in the environment. It restores the record afterwards.