Skip to content

Instantly share code, notes, and snippets.

@ConnerWill
Created April 15, 2025 19:24
Show Gist options
  • Save ConnerWill/353bfd320ac335af97c1f29286d9c866 to your computer and use it in GitHub Desktop.
Save ConnerWill/353bfd320ac335af97c1f29286d9c866 to your computer and use it in GitHub Desktop.
Simple script to update DDNS IP for DynuDNS domain
#!/usr/bin/env bash
# https://www.dynu.com/DynamicDNS/IPUpdateClient/cURL
#### OPTIONS
set -o errexit -o pipefail
#### DEFINITIONS
PROG=$(basename "${0}")
DDNS_USERNAME="${DDNS_USERNAME:-}"
DDNS_PASSWORD="${DDNS_PASSWORD:-}"
DDNS_HOSTNAME="${DDNS_HOSTNAME:-}"
DDNS_ALIAS="${DDNS_ALIAS:-}"
IPV4="${DDNS_IPV4:-auto}"
IPV6="${DDNS_IPV6:-no}"
#### FUNCTIONS
## Function to throw an error
function throw_error() {
local error_input="${1}"
printf "[ERROR]: %s\n" "${error_input}" >&2
exit 1
}
function is_installed(){
local input="${1}"
if ! command -v "${input}" >/dev/null 2>&1; then
throw_error "Cannot find '${input}' in PATH. Please make sure '${input}' is installed and is in your PATH"
fi
}
#### MAIN
is_installed "curl"
curl \
--location \
--user "${DDNS_USERNAME}:${DDNS_PASSWORD}" \
"https://api.dynu.com/nic/update?hostname=${DDNS_HOSTNAME}&myip=${IPV4}&myipv6=${IPV6}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment