Skip to content

Instantly share code, notes, and snippets.

Created January 6, 2021 21:05
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save LanceMcCarthy/6efd13c87d33567a7ec2bf5c067fab4e to your computer and use it in GitHub Desktop.
GoDaddy DDNS Trick
Write-Output "$(Get-Date -Format 'u') Quick & Dirty DDNS"
# Go to and get an API key + secret
$godaddy_api_key = ""
$godaddy_api_key_secret = ""
$godaddy_authorization = "sso-key $($godaddy_api_key):$($godaddy_api_key_secret)"
# We will be using the domans endpoint
# Lets say you want to update "", the hostname is 'wan' and domain is ''
$domain = ""
$hostname = "wan"
$request_uri = "$($domain)/records/A/$($hostname)"
# Getting current external IP address
Write-Output "Checking WAN IP Address..."
$wan_ip = Invoke-RestMethod -Uri ""
# Getting the DNS record IP address
Write-Output "Checking GoDaddy DNS Record..."
$dns_query_result = Invoke-RestMethod -Uri $request_uri -Headers @{ Authorization = $godaddy_authorization }
# Compare results
Write-Output "External IP: $($wan_ip), GoDaddy DNS IP: $($"
If ($ -eq $wan_ip) {
# If the IP addresses are identical, we're done.
Write-Output "[UNCHANGED] IP address has not changed, DNS update is not necessary."
else {
# If the IP address has changed, update the GoDaddy DNS record
Write-Output "[WAN IP CHANGED] The external IP address has changed. Updating $($hostname).$($domain) DNS record to $($wan_ip)."
Invoke-RestMethod -Method PUT -Uri $request_uri -Headers @{ Authorization = $godaddy_authorization } -ContentType "application/json" -Body "[{`"data`": `"$($myip)`"}]"
Copy link

You can run this on a schedule by using the Windows Task Scheduler app.


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