Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Created August 26, 2021 13:22
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ttscoff/fab7137c71d951d36b166622a4d5800d to your computer and use it in GitHub Desktop.
Namecheap DDNS for Synology
#!/bin/bash
## Namecheap DDNS updater for Synology
## Brett Terpstra <https://brettterpstra.com>
PASSWORD="$2"
DOMAIN="$3"
IP="$4"
PARTS=$(echo $DOMAIN | awk 'BEGIN{FS="."} {print NF?NF-1:0}')
# If $DOMAIN has two parts (domain + tld), use wildcard for host
if [[ $PARTS == 1 ]]; then
HOST='@'
DOMAIN=$DOMAIN
# If $DOMAIN has a subdomain, separate for HOST and DOMAIN variables
elif [[ $PARTS == 2 ]]; then
HOST=${DOMAIN%%.*}
DOMAIN=${DOMAIN#*.}
fi
RES=$(curl -s "https://dynamicdns.park-your-domain.com/update?host=$HOST&domain=$DOMAIN&password=$PASSWORD&ip=$IP")
ERR=$(echo $RES | sed -n "s/.*<ErrCount>\(.*\)<\/ErrCount>.*/\1/p")
if [[ $ERR -gt 0 ]]; then
echo "badauth"
else
echo "good"
fi
@aalejaandro
Copy link

Any instructions about how to install it?

@aalejaandro
Copy link

https://brettterpstra.com/2021/08/26/custom-urls-for-your-synology-with-namecheap/

Thank you for your kind and quick response.

Unfortunately it didn't work for me. :( I followed the steps as mentioned, and the platform shows the connection with Namecheap as correct, however the IP address is not updated.

Attached images.

image

image

@gwythan
Copy link

gwythan commented Aug 7, 2022

Thank you for this script! Are you able to improve the parsing logic so that it accepts TLDs with multiple parts? For example:
domain.co.uk
domain.com.au
domain.co.nz

Best regards

@ttscoff
Copy link
Author

ttscoff commented Aug 8, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment