Skip to content

Instantly share code, notes, and snippets.

@solibres
Forked from pedrom34/asuswrt-ovh-ddns.sh
Created June 21, 2022 22:15
Show Gist options
  • Select an option

  • Save solibres/c1b647046f11a780b099218a6cc17ce7 to your computer and use it in GitHub Desktop.

Select an option

Save solibres/c1b647046f11a780b099218a6cc17ce7 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