Google Domains Dynamic DNS Updater batch file for Windows 10, 11, and Linux bash. Updates DNS Record with IPv4 address of host machine, intended to be run on a schedule with Windows Task Scheduler or Cron.
Prior to editing the file, you will need to:
- Enable Dynamic DNS on your domain with Google in the managment pannel under the DNS tab (click show advanced settings)
- Note the hostname down for that record in it's entirety (including subdomain, if applicable)
- Click "View Credentials" and note down the provided username and password.
Open the .bat or .sh file in a text editor. The Variable Setup section should look like:
Rem Sets username var to Google Dynamic DNS API username to be ammended in the POST request.
set usr=
Rem Sets pw var to Google Dynamic DNS API Password to be ammended in the POST request.
set pw=
Rem Sets hostname var to the domain to be updated in the request.
set hostname=
Now,
- Change
set usr=
to equal the provided username from earlier. Should look like:set usr=ThisIsanAP1K3y
- Change
set pw=
to equal the provided password from earlier. Should look like:set pw=iAmapassw0rd
- Change
set hostanme=
to equal the target hostname. Should look like:set hostname=test.mason.com
- Save the file.
Now run the batch with command prompt . It should output good <your ip>
if the IP was successfully updated or nochg <your IP>
if it was already set correctly, meaning no change occured. If either output happened, congratulations, the batch file is correctly configured. If the output reads something different, check the response codes here
and adjust based on your response code.
Now you can run the batch file on a certian interval using taskschd.msc (Windows Task Scheduler) and it should run in the background automatically.
The API used for IP retrival is provided by ipify-api, as it outputs the simplest plaintext response, and is open source.
Linux users should give the script execute permissions (sudo chmod 777 DDNS.sh
for example)
and insert their DDNS username, password, and hostname inside the double quotes, rather than without on Windows. (Should look like usr="ThisIsanAP1K3y")