Last active
February 2, 2024 19:41
-
-
Save Pomdre/35ce178a5389bd4b9451412a9cdb2ff9 to your computer and use it in GitHub Desktop.
Domeneshop DDNS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.