Skip to content

Instantly share code, notes, and snippets.

@yetanotherchris
Created July 29, 2025 11:41
Show Gist options
  • Save yetanotherchris/ce37f000a11348017fcd3617f058019f to your computer and use it in GitHub Desktop.
Save yetanotherchris/ce37f000a11348017fcd3617f058019f to your computer and use it in GitHub Desktop.
duckdns.org updater (Powershell)
# PowerShell script to update DuckDNS IP address
param (
[Parameter(Mandatory=$true)]
[string]$Domain,
[Parameter(Mandatory=$true)]
[string]$Token
)
# Get current public IP address from Akamai
try {
$ip = Invoke-RestMethod -Uri "https://whatismyip.akamai.com/" -ErrorAction Stop
}
catch {
Write-Error "Failed to retrieve IP address from Akamai: $_"
exit 1
}
# Construct DuckDNS update URL
$updateUrl = "https://duckdns.org/update?domains=$Domain&token=$Token&ip=$ip"
# Send update request to DuckDNS
try {
$response = Invoke-RestMethod -Uri $updateUrl -ErrorAction Stop
if ($response -eq "OK") {
Write-Output "DuckDNS IP update successful for domain: $Domain, IP: $ip"
} else {
Write-Error "DuckDNS update failed with response: $response"
exit 1
}
}
catch {
Write-Error "Failed to update DuckDNS: $_"
exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment