Skip to content

Instantly share code, notes, and snippets.

@Pomdre
Last active February 2, 2024 19:41
Show Gist options
  • Save Pomdre/35ce178a5389bd4b9451412a9cdb2ff9 to your computer and use it in GitHub Desktop.
Save Pomdre/35ce178a5389bd4b9451412a9cdb2ff9 to your computer and use it in GitHub Desktop.
Domeneshop DDNS
#!/bin/bash
set -euo pipefail
# Update Domeneshop DNS record using DDNS (https://api.domeneshop.no/docs/#tag/ddns)
API_KEY="your_apikey"
API_SECRET="your_secret"
DOMAIN="example.com"
SUBDOMAINS=(
www
subdomain2
)
# Use ipv4 or ipv6 as the client adress, this will be the ip in the dns record
PROTOCOL="ipv4"
update_dns() {
local hostname=$1
echo "Updating DNS for ${hostname}"
curl --fail --${PROTOCOL} -sS "https://${API_KEY}:${API_SECRET}@api.domeneshop.no/v0/dyndns/update?hostname=${hostname}"
}
# Main domain
update_dns "${DOMAIN}"
# Subdomains
for subdomain in "${SUBDOMAINS[@]}"; do
full_hostname="${subdomain}.${DOMAIN}"
update_dns "${full_hostname}"
done
@Pomdre
Copy link
Author

Pomdre commented Feb 2, 2024

Update DNS using the "IP update protocol".

A DNS record for the given hostname will be created if it does not exist, or updated if it does. The record type (A or AAAA will automatically be detected if the record exist or it will be created).

The IP of the client making the API request will be used as the dns endpoint.

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