Skip to content

Instantly share code, notes, and snippets.

@maurerle
Last active June 28, 2025 14:47
Show Gist options
  • Save maurerle/3bb419a119354a41d0b7edbecd3788ef to your computer and use it in GitHub Desktop.
Save maurerle/3bb419a119354a41d0b7edbecd3788ef to your computer and use it in GitHub Desktop.
This gist updates ipv6 and ipv4 address using dyndns for a ionos domain
#!/bin/bash
# === Configuration ===
API_KEY=${1:-"YOUR API KEY"}
INTERFACE=${2:-"eth0"}
IONOS_API_URL="https://ipv4.api.hosting.ionos.com/dns/v1/dyndns"
# === Get global IPv6 address of the interface ===
IPV6_ADDR=$(ip -6 addr show dev "$INTERFACE" scope global | grep -oP '(?<=inet6\s)[0-9a-f:]+(?=/)' | head -n1)
IPV4_ADDR=$(curl -s ipv4.icanhazip.com)
if [ -z "$IPV6_ADDR" ]; then
echo "No global IPv6 address found on $INTERFACE"
exit 1
fi
# === Send GET request to IONOS ===
curl -s -X GET "${IONOS_API_URL}?q=${API_KEY}&ipv4=${IPV4_ADDR}&ipv6=${IPV6_ADDR}"
# === Output result ===
if [ $? -eq 0 ]; then
echo "Successfully sent IPv6 address: $IPV6_ADDR"
else
echo "Failed to send IPv6 update $IPV6_ADDR"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment