Skip to content

Instantly share code, notes, and snippets.

@linux4life798
Last active December 9, 2023 04:15
Show Gist options
  • Save linux4life798/81b3e7e51fe444ecb5c86a4070bee249 to your computer and use it in GitHub Desktop.
Save linux4life798/81b3e7e51fe444ecb5c86a4070bee249 to your computer and use it in GitHub Desktop.
Setup ddclient config for Google Nest router and Cloudflare using https://github.com/linuxserver/docker-ddclient
# This is an example ddclient configuration that uses fetch-nest-wan-ipv4.sh
# and Cloudflare.
# The fetch-nest-wan-ipv4.sh script must be in whatever working directory ddclient
# is run from, or change the below path to the command to be absolute.
######################################################################
##
## Define default global variables with lines like:
## var=value [, var=value]*
## These values will be used for each following host unless overridden
## with a local variable definition.
##
## Define local variables for one or more hosts with:
## var=value [, var=value]* host.and.domain[,host2.and.domain...]
##
## Lines can be continued on the following line by ending the line
## with a \
##
##
## Warning: not all supported routers or dynamic DNS services
## are mentioned here.
##
######################################################################
######################################################################
daemon=0 # check the default time (I think every 60s)
syslog=yes # log update msgs to syslog
#mail=root # mail all msgs to root
#mail-failure=root # mail failed update msgs to root
pid=/var/run/ddclient/ddclient.pid # record PID in file.
ssl=yes # use ssl-support. Works with ssl-library
# postscript=script # run script after updating. The
# new IP is added as argument.
##
## Fetch the IPv4 WAN address from the Google/Nest WiFi router.
## Use cmd="bash fetch-nest-wan-ipv4.sh" if you are running from a Docker volume,
## since you may not be able to set exec permission.
##
use=cmd, cmd=fetch-nest-wan-ipv4.sh
##
## Uncomment the following lines if things aren't working. It will fetch your WAN IP using ipify.org.
##
#use=web, web=https://api.ipify.org/
##
## CloudFlare (www.cloudflare.com)
##
## The linuxserver/docker-ddclient container runs envsubst to replace these environment variables.
## $CLOUDFLARE_DOMAIN is the top level domain/zone, like example.com
## $CLOUDFLARE_API_KEY is the cloudflare api key that can write to the above zone
## $CLOUDFLARE_SUB_DOMAIN_CSV is the comma seperated list of sub domains to update, like one.example.com,two.example.com
##
protocol=cloudflare, \
zone=$CLOUDFLARE_DOMAIN, \
ttl=1, \
login=token, \ # Only needed if you are using your global API key. If you are using an API token, set it to "token" (wihtout double quotes).
password=$CLOUDFLARE_API_KEY \ # This is either your global API key, or an API token. If you are using an API token, it must have the permissions "Zone - DNS - Edit" and "Zone - Zone - Read". The Zone resources must be "Include - All zones".
$CLOUDFLARE_SUB_DOMAINS_CSV
#!/bin/sh
#
# Craig Hesling
#
# This script will query your Google/Nest WiFi router for its WAN IPv4 address.
# It is intended for use with ddclient, so that it doesn't need to query an
# external third-party IP checker website. This allows for more frequent IP
# checks with the concerns for errors or being blocked.
#
# This API reference comes from https://github.com/olssonm/google-wifi-api.
#
# In your ddclient.conf, use the following snippet:
# use=cmd, cmd=fetch-nest-wan-ipv4.sh
NEST_ROUTER_HOST=${NEST_ROUTER_HOST:-192.168.86.1}
curl --silent --show-error http://$NEST_ROUTER_HOST/api/v1/status | \
jq --raw-output '.wan.localIpAddress'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment