"Unauthorized" (HTTP 401) trying to access dyndns

Advanced feature discussion, beta programs and unsupported "Labs" features.
5 posts Page 1 of 1
by rknop » Mon Oct 30, 2023 7:05 am
I'm trying to set up a cron job to regularly update my DNS record for my home IP with the dyndns service, but I'm not able to get it to work.

I own the domain rknop.net, and sonic is where I have it registered. (I usually update records using the web interface at Sonic member tools.)

I run:

Code: Select all

curl -X POST https://public-api.sonic.net/dyndns/api_key --data '{"username": "rknop", "password": "<password>", "hostname": "home.rknop.net" }'
(where I have put the right thing in for <password> -- that's not really my password!). I get back an HTTP 401 (unauthorized).

Is there something I'm doing wrong here?
by ngufra » Mon Oct 30, 2023 9:56 am
I have never had success with this sonic dynamic dns service.

The way i do it is

I use no-ip (free service). I have a host name <myhost>.ddns.net there.

Then at my hosting, I added a CNAME record to redirect from home.<mydomain.org> to <myhost>.ddns.net

Then if i access http://home.<mydomain.org>:81, it will query <myhost>.ddns.net:81
I have a port forwarding on the router to say which local device to send requests for port 81 for example 192.168.1.13:80 (and I have dhcp to always give 192.168.1.13 to the mac address of the pc i have running the web server on port 80, and the pc has firewall opened for that port)

I just saw that my hosting (that is running cpanel) offers a dynamic dns service so maybe i could simplify and not need op-ip.

Let me know how it works for you.
by drew.phillips » Mon Oct 30, 2023 2:17 pm
For the hostname, can you try "rknop.net" instead of "home.rknop.net" and see if that works?

You want to use the domain name that has DNS hosting with Sonic which is the latter. Once you have an API key for that domain, you can add a A record to point home.rknop.net to your IP.

Your request for the API key will look like this:

Code: Select all

curl -X POST -H "Content-Type: application/json" \
  --data '{"username": "rknop", "password": "<password>", "hostname": "rknop.net" }' \
  https://public-api.sonic.net/dyndns/api_key
Then, once you have an API key, you can add or update the A record for your subdomain like this:

Code: Select all

curl -X PUT -H "Content-Type: application/json" \
  --data '{"userid":"<your_userid>","apikey":"<your_api_key>","hostname":"home.rknop.net","value":"1.2.3.4","type":"A"}' \
  https://public-api.sonic.net/dyndns/host
Drew Phillips
Programmer / System Operations, Sonic.net
by rknop » Mon Oct 30, 2023 3:08 pm
Aha, that was the answer! Thank you.
by drew.phillips » Mon Oct 30, 2023 4:19 pm
Thanks for confirming that those changes worked! Glad you were able to get the DynDNS API working for your needs.
Drew Phillips
Programmer / System Operations, Sonic.net
5 posts Page 1 of 1

Who is online

In total there are 17 users online :: 0 registered, 0 hidden and 17 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: No registered users and 17 guests