Skip to content

Instantly share code, notes, and snippets.

@pedrom34
Last active June 21, 2022 22:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pedrom34/0bfdf2bb7f2e17a8859c1fad7204d7bf to your computer and use it in GitHub Desktop.
Save pedrom34/0bfdf2bb7f2e17a8859c1fad7204d7bf to your computer and use it in GitHub Desktop.
Working (tested) asuswrt-merlin Custom DDNS script for OVH with Double NAT option
#!/bin/sh
###
# Based on
# https://github.com/RMerl/asuswrt-merlin/wiki/Custom-DDNS#google-domains
# https://github.com/RMerl/asuswrt-merlin/wiki/Custom-DDNS#bind9-ddns-using-nsupdate
#
# Forked from
# https://gist.github.com/atais/9ea6595072096ab8077f619bd3648da8
###
set -u
U=user
P=password
H=domain
# args: username password hostname ip
ovh_dns_update() {
CMD=$(curl -s -u $1:$2 "https://www.ovh.com/nic/update?system=dyndns&hostname=$3&myip=$4")
logger "ovh-ddns-updated: $CMD"
case "$CMD" in
good*|nochg*) /sbin/ddns_custom_updated 1 ;;
*) /sbin/ddns_custom_updated 0 ;;
esac
}
### When double NATed behind ISP's router this line gets IP from outside, otherwise, comment out next line.
IP=$(wget -O - -q http://myip.dnsomatic.com/)
# last parameter is IP, use $IP
ovh_dns_update $U $P $H $IP
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment