What's new

Custom DDNS Script - Unauthorized Error

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Trent Hubbert

Occasional Visitor
Setting up a ddns script for RT-AC68U using the following script. (with the pass and usernames changed). I get an error esults: HTTP/1.1 401 Unauthorized^M Server: in the log file. I just installed entware but not sure what packages if any are required. I verified that the https://$username... works from the browser so I know the password and username is correct. Any ideas?


#!/bin/sh
# Update the following variables:
USERNAME=dnsomatic_username
PASSWORD=dnsomatic_password
HOSTNAME=all.dnsomatic.com

# Should be no need to modify anything beyond this point
/usr/sbin/curl -k --silent "https://$USERNAME:$PASSWORD@updates...ME&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG&myip=" > /dev/null
if [ $? -eq 0 ]; then
/sbin/ddns_custom_updated 1
else
/sbin/ddns_custom_updated 0
fi
 
... I get an error results: HTTP/1.1 401 Unauthorized^M Server: in the log file. ... Any ideas?
Try replace the line:
Code:
/usr/sbin/curl --silent --cacert /rom/ca-bundle.crt "https://$USERNAME:$PASSWORD@updates...ME&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG&myip=" > /dev/null
 
Here is the fix. Any special characters ($,@,(,), etc.) in the username or password must be replaced with the %URL equivalents.
 
EDIT: curl will automatically url encode the data as shown below

Also, notice how you can specify your WAN IP address to DNS-O-Matic in the request.

/jffs/scripts/ddns-start
Code:
#!/bin/sh
WAN_IP="$1"
# Update the following variables:
USERNAME=""
PASSWORD=""
HOSTNAME=""

# Should be no need to modify anything beyond this point
/usr/sbin/curl --get --silent --cacert /rom/ca-bundle.crt https://updates.dnsomatic.com/nic/update --data-urlencode hostname=${HOSTNAME}&myip=${WAN_IP}&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG --user ${USERNAME}:${PASSWORD} >/dev/null 2>&1
if [ $? -eq 0 ]; then
  /sbin/ddns_custom_updated 1
else
  /sbin/ddns_custom_updated 0
fi
 
Last edited:

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top