Duckdns configuration in ddclient

Started by yeraycito, June 25, 2023, 04:12:18 AM

Previous topic - Next topic
1: Stop ddclient

2: Access via ssh with Filezilla or similar to /usr/local/sbin

3: Download and edit the file ddclient

4: We need to replace what appears from line 6370 onwards with the following:

######################################################################
## nic_duckdns_update
## by George Kranis (copypasta from nic_dtdns_update)
## https://www.duckdns.org/update?domains=mydomain1,mydomain2&token=xxxx-xxx-xx-x&ip=x.x.x.x
## response contains OK or KO
######################################################################
sub nic_duckdns_update {
    debug("\nnic_duckdns_update -------------------");

    ## update each configured host
    ## should improve to update in one pass
    foreach my $h (@_) {
        my $ip = delete $config{$h}{'wantip'};
        info("setting IP address to %s for %s", $ip, $h);
        verbose("UPDATE:", "updating %s", $h);

        # Set the URL that we're going to to update
        my $url;
        $url  = "https://$config{$h}{'server'}/update";
        $url .= "?domains=";
        $url .= $h;
        $url .= "&token=";
        $url .= $config{$h}{'password'};
        $url .= "&ip=";
        $url .= $ip;


        # Try to get URL
        my $reply = geturl(proxy => opt('proxy'), url => $url);

        # No response, declare as failed
        if (!defined($reply) || !$reply) {
            failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
            next;
        }
        next if !header_ok($h, $reply);

        my @reply = split /\n/, $reply;
        my $state = 'noresult';
        my $line = '';

        foreach $line (@reply) {
            if ($line eq 'OK') {
                $config{$h}{'ip'}     = $ip;
                $config{$h}{'mtime'}  = $now;
                $config{$h}{'status'} = 'good';
                $state = 'result';
                success("updating %s: good: IP address set to %s", $h, $ip);

            } elsif ($line eq 'KO') {
                $config{$h}{'status'} = 'failed';
                $state = 'result';
                failed("updating %s: Server said: '%s'", $h, $line);
            }
        }

        if ($state eq 'noresult') {
            failed("updating %s: Server said: '%s'", $h, $line);
        }
    }
}

######################################################################
## nic_freemyip_examples
######################################################################

5: Replace the modified file with the existing one.

6: We put ddclient up and running

7: Add a new duckdns account:

Service: Duck DNS

Username: blanck

Password: TOKEN

Hostname: xxxxxxx.duckdns.org

Check ip method: Interface

Interface to monitor: WAN

Force SSL: Disabled



Due to ddclient being poorly structured I think this is still broken in the last version released by upstream in lack of a new release they should be pushing out.


Cheers,
Franco

Quote from: franco on June 27, 2023, 01:45:42 PM
Due to ddclient being poorly structured I think this is still broken in the last version released by upstream in lack of a new release they should be pushing out.


Cheers,
Franco

The code that fixes the problem is already included here but is not included in the latest stable version;

https://github.com/ddclient/ddclient/blob/master/ddclient.in

Yes that's what I said.

I'm not unwilling to pull this code in early in lack of a proper release but I need to be careful about spending too much community time on this -- I've recently debugged and contributed the dyndns2 fix and at some point we need to get 23.7 out the door.


Cheers,
Franco

Hi all, has that fix been finally pulled? For my part it seems not, as i still struggle to get the DynDns Updates on Duckdns done. Any idea when that will land in stable. If its not to far ahead i would hesitate to manually patch it.

Yes. I have a DuckDNS account and it works with ddclient since 23.7.1 and will work with the native (OPNsense) backend in 23.7.2 as support was added there too.


Cheers,
Franco

After updating to 23.7.2 and deleting and reconfiguring it didn't work at my end at first. Only when i tuned the log level up (for somewhat magical reasons) it started to work again. Il try it with a vanilla setting in the days to come and should it turn out that i was a systematic error i will try to describe it here. In the meantime i consider this issue fixed. Thanks for your quick response @franco

September 02, 2023, 11:17:14 PM #11 Last Edit: September 02, 2023, 11:18:57 PM by dg6464
Just updated to 27.7.3, with latest os-ddclient 1.15, and everything is working fine with DuckDNS, right away for me (for the first time).

Thanks for the hard work on getting this up and running and stable.

I've spent a long time waiting to move from the legacy DDNS client, but could never get the os-ddclient stable and working with DuckDNS.

I had even JUST switched to a DuckDNS container on unRAID (it worked within 1 second of booting the first time)... as I upgraded to OPNsense 27.7.1... and still couldn't get os-ddclient working properly.

Decided to give it one last go with OPNsense's os-ddclient when I saw this thread, and it worked immediately, without any editing of files, or manipulating of the underlying configuration files via SSH.

So I've removed the unRAID docker with the hope that this stays solid between reboots.

My Working Settings:

General ->

Interval = 600 seconds
Backend = native

Accounts ->

Service = duckdns
Username = blank
Password = <token>
Hostnames = hostname.duckdns.org
Check ip method = Interface [IPv4]
Interface to monitor = WAN
Check ip timeout = 10
Force SSL = unchecked

Thanks again!

Just went through the duckdns setup, didn't uncheck Force SSL - everything works fine

The only weird thing was the Check IP method, was getting a strange IP for the WAN when checkin with external services - all good when checking the interface

Quote from: dg6464 on September 02, 2023, 11:17:14 PM
Just updated to 27.7.3, with latest os-ddclient 1.15, and everything is working fine with DuckDNS, right away for me (for the first time).

Thanks for the hard work on getting this up and running and stable.

I've spent a long time waiting to move from the legacy DDNS client, but could never get the os-ddclient stable and working with DuckDNS.

I had even JUST switched to a DuckDNS container on unRAID (it worked within 1 second of booting the first time)... as I upgraded to OPNsense 27.7.1... and still couldn't get os-ddclient working properly.

Decided to give it one last go with OPNsense's os-ddclient when I saw this thread, and it worked immediately, without any editing of files, or manipulating of the underlying configuration files via SSH.

So I've removed the unRAID docker with the hope that this stays solid between reboots.

My Working Settings:

General ->

Interval = 600 seconds
Backend = native

Accounts ->

Service = duckdns
Username = blank
Password = <token>
Hostnames = hostname.duckdns.org
Check ip method = Interface [IPv4]
Interface to monitor = WAN
Check ip timeout = 10
Force SSL = unchecked

Thanks again!

Perfect, thanks for the setup instructions - was scratching my head as to why I wasn't getting an IP showing on Opnsense, also I'd put a username where none was needed. Total newb here but again, thank you :)

Sorry for inserting myself into this thread, but it still doesn't work for me.

OpnSense was installed from scratch two days ago and immediately updated.
The backend is "ddclient", but even with "native" it doesn't work.
The account settings are:
Service = duckdns
Username = blank
Password = <token>
Hostnames = hostname.duckdns.org
Check ip method = Interface [IPv4]
Interface to monitor = WAN
Check ip timeout = 10
Force SSL = unchecked

The date reported in "Updated" is two days ago, but the IP is that of the opnsense WAN address (192.168.x.y), not the public address from the ISP.
Also in the duckdns.org panel the domain corresponds to this private IP and not the public one of the ISP.

Then, if I then type "ping hostname.duckdns.org" from my Win11 terminal I get the error "The host hostname.duckdns.org could not be found. Check that the name is correct and try again."

Can you suggest me some other free DDNS that doesn't have to continuously update the registered profile?