Skip to content

Instantly share code, notes, and snippets.

@ZEROF
Created June 23, 2024 21:53
Show Gist options
  • Save ZEROF/c3c45d94eeb163adf98b1a933ffaeae4 to your computer and use it in GitHub Desktop.
Save ZEROF/c3c45d94eeb163adf98b1a933ffaeae4 to your computer and use it in GitHub Desktop.
myaddr.tools DNS update script and setting with systemd

myaddr.tools

A minimalist dynamic DNS service

Features

  1. No ads, no tracking, no nonsense
  2. Get a name in seconds, no account required
  3. Easy, forgiving HTTP-based API
  4. Multiple domains (all resolve the same): - your-name.myaddr.tools - your-name.myaddr.dev (on the HSTS preload list) - your-name.myaddr.io
  5. ACME dns-01 challenge support for TLS certificates from CAs like Let's Encrypt

First we need simple bash script inside /usr/local/bin. I will name this script updatedns.sh. All what you need to change here is YOURKEY value with your key.

#!/bin/bash
curl -d key=YOURKEY -d ip=self https://myaddr.tools/update

Set permission: chmod +x /ust/local/bin/updatedns.sh

Now we create service script here /etc/systemd/system/myaddrdns.service

[Unit]
Description=Update MyAddr.tools DNS Entries

[Service]
ExecStart=/usr/local/bin/updatedns.sh

[Install]
WantedBy=default.target

Enable and start service: sudo systemctl enable myaddrdns.service && sudo systemctl start myaddrdns.service

As we need to send API request every 90 days to keep our free domain active, we must set systemd times as well here /etc/systemd/system/myaddrdns.timer. In case you have static IP, timer can run weekly.

[Unit]
Description=Update MyAddr.tools DNS Entries

[Timer]
OnCalendar=weekly
Persistent=true

[Install]
WantedBy=timers.target

Enable and start service: sudo systemctl enable myaddrdns.timer && sudo systemctl start myaddrdns.timer

For testing I advice you to start with value "minutely" and replace it or not later on with "weekly", when you are sure that everything is working as it should.

Check if timer is listed: systemctl list-timers, you should see:

image

Check logs: watch -n 5 journalctl -u myaddrdns.service

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment