Advertisement
anonit

GoDaddy Dynamic DNS Update

Nov 30th, 2017
1,562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2. This script is used to check and update your GoDaddy DNS server to the IP address of your current internet connection.
  3.  
  4. First go to GoDaddy developer site to create a developer account and get your key and secret
  5.  
  6. https://developer.godaddy.com/getstarted
  7.  
  8. Update the first 4 varriables with your information
  9.  
  10. Details:
  11. https://au.godaddy.com/community/Managing-Domains/Dynamic-DNS-Updates/td-p/7862
  12. https://github.com/markafox/GoDaddy_Powershell_DDNS/blob/master/godaddy_ddns.ps1
  13.  
  14. #>
  15. $domain = 'anonit.net'  # your domain
  16. $name = 'mail','@' #name of the A record to update, can be multiples
  17. $key = 'This_is_a_fake_key_kfajewq8wu30r28wjlksJDF90*23f' #key for godaddy developer API
  18. $secret = 'Not_a_real_secret_alwkjf9832wj4f2LKJ8ejcas' #Secret for godday developer API
  19.  
  20. $headers = @{}
  21. $headers["Authorization"] = 'sso-key ' + $key + ':' + $secret
  22. $result = Invoke-WebRequest https://api.godaddy.com/v1/domains/$domain/records/A/$name -method get -headers $headers
  23. $content = ConvertFrom-Json $result.content
  24. $dnsIp = $content.data
  25.  
  26. # Get public ip address there are several websites that can do this.
  27. $currentIp = Invoke-RestMethod http://ipinfo.io/json | Select -exp ip
  28.  
  29. ForEach ($dnsname in $name) {
  30.     if ( $currentIp -ne $dnsIp) {
  31.         $Request = @{ttl=600;data=$currentIp }
  32.         $JSON = "[" + (Convertto-Json $request) + "]"
  33.         Invoke-WebRequest https://api.godaddy.com/v1/domains/$domain/records/A/$dnsname -method put -headers $headers -Body $json -ContentType "application/json"
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement