Ddns-scripts DDNS update to WHM/cPanel using github.com/raceybe/cpanel-ddns

Hi all,

I've set up the following script on a cPanel subdomain and, using the included documentation can see that is working, by using the included test script. (i.e. visiting https://ddns.example.com/testclient.php)
https://github.com/raceybe/cpanel-ddns

I'm struggling to provide [Services] > Dynamic DNS (luci-app-ddns(ddns-scripts)) with a URL that will work with this PHP script.
At the moment I have:
https://[USERNAME]:[PASSWORD]@ddns.example.com/update?hostname=[DOMAIN]&myip=[IP]
but the PHP script at ddns.example.com returns 'Authorization malformed', which, according to the update.php script, means no BASIC HTTP authentication.

Could anyone with experience using custom ddns-scripts and PHP help?

Cheers

Here is it:

But most important is that your cPanel must enable API.

Hi,

Yes, this is the script I'm using and, as I mentioned, it's working using the testclient.php script included in the repo.
However, it doesn't work when I attempt to configure luci-app-ddns in OpenWRT

As the test script from the GitHub repo is working, I must assume the cPanel API is enabled.

Can you try to execute this using CURL?

Like open terminal and type:
curl https://[USERNAME]:[PASSWORD]@ddns.example.com/update?hostname=[DOMAIN]&myip=[IP]
and see what's going on.

Hi Peter,

When I do this on either the server hosting the DDNS change script or the OpenWRT router using the DDNS update script, the result is '911 new IP address not specified.'

The result as ever in the Dynamic DNS > Log File Viewer in OpenWRT is '911 Authorization malformed.'

Just playing around, I thought I'd add this if it helps:

Using
http://[USERNAME]:[PASSWORD]@ddns.example.com/update?hostname=[DOMAIN]&myip=[IP] with the ampersand, result in 'new IP address not specified' on both cPanel server and OpenWRT SSH, HOWEVER, in the Log File Viewer for Dynamic DNS, the error is '911 Authorization malformed'

I put var_dump($_GET); on line 14 in update.php and this shows me the IP address is there in Dynamic DNS > Log File Viewer

This is the result from SSH on the cPanel server

curl https://openwrt:*************@ddns.example.com/nic/update?hostname=myddnsname.example.com
[cpanelaccount@whmserver]$ curl https://openwrt:*************@ddns.example.com/nic/update?hostname=myddnsname.example.com&myip=1.2.3.4
[1] 120303
[cpanelaccount@whmserver]$ array(1) {
  ["hostname"]=>
  string(30) "myddnsname@example.com"
}
911 new IP address not specified^C
[1]+  Done                    curl https://openwrt:************@ddns.example.com/nic/update?hostname=myddnsname.example.com

This is a snippet from the Dynamic DNS > Log File Viewer on OpenWRT

 192109       : #> /usr/bin/wget-ssl --hsts-file=/tmp/.wget-hsts -nv -t 1 -O /var/run/ddns/ddnsupdateservicename.dat -o /var/run/ddns/ddnsupdateservicename.err --no-proxy 'http://openwrt:********@ddns.example.com/update?hostname=myddnsname.example.com&myip=1.2.3.4'
 192109       : DDNS Provider answered:
array(2) {
  ["hostname"]=>
  string(30) "myddnsname.example.com"
  ["myip"]=>
  string(13) "1.2.3.4"
}
911
Authorization malformed
 192110  info : Update successful - IP '1.2.3.4' send
 192110  info : Forced update successful - IP: '1.2.3.4' send
 192110       : Waiting 600 seconds (Check Interval)

I can see it. When you have & in URL it need to be called as:
curl "urlwith&in"
so quotes "" prevent part of this to be spawn as background process.

Hi Peter,

I am also chatting to the author of the script on GitHub and we've come to the same realisation!
If I use curl from SSH, the update URL works fine, but when specified in LuCI > Dynamic DNS, the problem occurs.
I tried putting quotes around the update URL, but LuCI doesn't like that

Peter, would you know how to make ddns-scripts use curl instead of wget?
The documentation says this is possible but doesn't seem to explain how

1 Like

Thanks again vgaetera, I now have working WireGuard and my own DDNS provider working in no small part thanks to you!
Thanks also to Peter whose suggestion to try from the command line with curl helped.
Getting curl to be the default was the answer to making that cPanel script work. I'm afraid, once again, I was not fully understanding the documentation.

For anyone else who'd like to run their own DDNS provider (if you have cPanel for example), the script from raceybe on GitHub is working well; Just make sure to install curl and ca-bundle (follow the ddns-scripts documentation).
To enable curl as the default for ddns-scripts, add option use_curl '1' to the config ddns 'global' section of /etc/config/ddns

1 Like

It's piece of cake!

wget --user user --password pass http://example.com/