Created
July 29, 2025 11:41
-
-
Save yetanotherchris/ce37f000a11348017fcd3617f058019f to your computer and use it in GitHub Desktop.
duckdns.org updater (Powershell)
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
# 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