Using Google domains with a dynamic IP

This is a script to read the current public IP and update your Google domain with the new IP-

#get the current IP
$url = "https://ifconfig.co/json"
$ip = Invoke-RestMethod $url
#send the new IP to Google
$updateCommand = "https://username:[email protected]/nic/update?hostname=dynamic.domain.com&myip=$($ip.ip)"
Invoke-RestMethod $updateCommand

Here is some documentation on Google on how to change your DNS via API- https://support.google.com/domains/answer/6147083. The short version is make a domain or subdomain dynamic. When you do this there will be a username and password generated for you, use this in the above script.


Posted

in

,

by

Tags: