Skip to content

Instantly share code, notes, and snippets.

@ql-owo-lp
Last active March 12, 2023 00:04
Show Gist options
  • Star 19 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save ql-owo-lp/f7a5d5402887ca1b5b2c399c60e0921f to your computer and use it in GitHub Desktop.
Save ql-owo-lp/f7a5d5402887ca1b5b2c399c60e0921f to your computer and use it in GitHub Desktop.
Asus-Merlin-DuckDNS
#!/bin/sh
# register a subdomain at https://www.duckdns.org/ to get your token
# put 'hostname:token' in the 'Host Name' field under DDNS
# e.g. myhost:abcdefgh-1234-5678-9876-f71b0ed7a7fe
DDNS_HOSTNAME_FIELD=$(nvram get ddns_hostname_x)
SUBDOMAIN=$(echo "$DDNS_HOSTNAME_FIELD" | awk -F':' '{print $1}')
TOKEN=$(echo "$DDNS_HOSTNAME_FIELD" | awk -F':' '{print $2}')
IPV4=$(nvram get wan0_ipaddr)
IPV6=$(nvram get ipv6_wan_addr | awk -F'/' '{print $1}')
REQUEST_URL="https://www.duckdns.org/update?domains=${SUBDOMAIN}&token=${TOKEN}&ip=${IPV4}&ipv6=${IPV6}"
logger "DDNS Request URL: ${REQUEST_URL}"
# no modification below needed
RESULT=$(curl --silent "${REQUEST_URL}" 2>&1)
logger "DDNS Request result: $RESULT"
if [[ "$RESULT" == "OK" ]];
then
/sbin/ddns_custom_updated 1
else
/sbin/ddns_custom_updated 0
fi
@Markieta
Copy link

For newer versions I had to change -F'|' to -F':', e.g., myhost:abcdefgh-1234-5678-9876-f71b0ed7a7fe

@laxdog
Copy link

laxdog commented Feb 13, 2023

I had the same problem with the |, changed it to : also. Thanks @Markieta

@ql-owo-lp
Copy link
Author

I have updated the script, thanks.

@Markieta
Copy link

Cool! You should update the comments at the top as well.

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