Skip to content

Instantly share code, notes, and snippets.

@coffeejoshua
Last active July 18, 2025 20:21
Show Gist options
  • Save coffeejoshua/69d2802ab579839ab6f30c5c75f99e82 to your computer and use it in GitHub Desktop.
Save coffeejoshua/69d2802ab579839ab6f30c5c75f99e82 to your computer and use it in GitHub Desktop.
A bash client to update Dynamic DNS (such as duckdns)
#!/bin/bash
# Designed to be invoked every 5 minutes by cron
# See: https://www.duckdns.org/install.jsp
# crontab -e
# */5 * * * * /home/rpi/duckdns/update-duck.sh >/dev/null 2>&1
MYDOMAIN='your-sub-domain'
TOKEN='your-token'
LOGFILE='/home/rpi/duckdns/duck-history.log'
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
RESPONSE=$(curl -s "https://www.duckdns.org/update?domains=${MYDOMAIN}&token=${TOKEN}&ip=")
if [ "$RESPONSE" = "OK" ]; then
echo "$TIMESTAMP - successful" >> "${LOGFILE}"
else
echo "$TIMESTAMP - failed: $RESPONSE" >> "${LOGFILE}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment