Skip to content

Instantly share code, notes, and snippets.

@antoniodvr
Created July 28, 2020 21:31
Show Gist options
  • Save antoniodvr/1193d29a37e01bbcad6a1f463a31467e to your computer and use it in GitHub Desktop.
Save antoniodvr/1193d29a37e01bbcad6a1f463a31467e to your computer and use it in GitHub Desktop.
Google Domains Dynamic DNS Update Script
#!/bin/bash
### Google Domains provides an API to update a DNS "Syntheitc record". This script
### updates a record with the script-runner's public IP, as resolved using a DNS
### lookup.
###
### Google Dynamic DNS: https://support.google.com/domains/answer/6147083
### Synthetic Records: https://support.google.com/domains/answer/6069273
HOSTNAME="yoursubdomain.domain.tld"
USERNAME="yourdyndnsuser"
PASSWORD="yourdyndnspassword"
IP=$(curl -s "https://domains.google.com/checkip")
URL="https://domains.google.com/nic/update?hostname=${HOSTNAME}&myip=${IP}"
curl --user ${USERNAME}:${PASSWORD} -s $URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment