Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@LenardHess
Copy link
Contributor

@LenardHess LenardHess commented Jul 29, 2023

This is the first iteration of implementing the IONOS provider requested in #555

Outstanding tasks:

  • Add example configuration to reference ddclient.conf
  • Fix multi-host setups to update per-update-URL instead of per-host
  • Opt.: Reach out to IONOS to request better documentation of the &ipv4=, &ipv6= parameters in the update URL.
  • Change request to GET
  • Fix docs example (remove comma from password)

Configuration snippet for this provider:

protocol=ionos \
password=1234567890ABCDEF \
host.example.com

password is the secret part of the update URL, e.g.
https://ipv4.api.hosting.ionos.com/dns/v1/dyndns?q=ZsWxJSLcX8Dpy40nu0fhycBXdnnTb0gM2yqKS3Xcmx4c3yA6EhZp3Sg0467MRvdn6dU4P0kQntSeskxpYsFMxXnrKmW8teSHSHc3eefgYu4tjb2veJH4tESXaTmW4tvNW6nrtSm6Vb6E7e2SpuqqjvFaqbBS4XGCS
would mean that password=ZsWxJSLcX8Dpy40nu0fhycBXdnnTb0gM2yqKS3Xcmx4c3yA6EhZp3Sg0467MRvdn6dU4P0kQntSeskxpYsFMxXnrKmW8teSHSHc3eefgYu4tjb2veJH4tESXaTmW4tvNW6nrtSm6Vb6E7e2SpuqqjvFaqbBS4XGCS


The support for IPv6 is (afaics) only documented in the german setup instructions, where they show an example to configure a FRITZ!Box (see screenshot below). The URL in question has angle brackets as placeholders, which the FRITZ!Box replaces with the relevant IPs.

Docs snippet (from here)
image

@twoellert
Copy link

twoellert commented Aug 11, 2023

Hey!

Since I also need an IONOS update feature for ddclient I took the liberty of testing your code changes.

They were not working right out of the box. Found two issues:

GET instead of POST needed

IONOS expects a GET request. Currently in the code its set as POST request. If you try it as POST you get an error message from the IONOS API:

RECEIVE:  {"message":"Invalid API key format."}
FAILED:   test.xxx.xxx -- Failed to update.

Changing line 5865 to GET fixed that issue:

my $reply = geturl(
            proxy     => opt('proxy'),
            url       => $url,
            method    => 'GET',
            login     => undef,
            password  => undef,
            ipversion => $ipversion,
);

The GET is also described in the IONOS documentation (german only):
https://www.ionos.de/hilfe/domains/ip-adresse-konfigurieren/dynamisches-dns-ddns-einrichten-bei-company-name/

Configuration

2nd problem I found was more documentation related. In ddclient.in the description is as follows:

Example ${program}.conf file entries:
  ## Single host update.
  protocol=ionos,                           \\
  password=1234567890ABCDEF,                \\
  host.example.com

  ## Multiple host update.
  protocol=ionos,                           \\
  password=1234567890ABCDEF,                \\
  hosta.example.com,hostb.sub.example.com

But if you add the comma at the end of the password line the generated update URL in the code will also include that comma.

What worked for me was the following without comma:

protocol=ionos, \
password=MYAPIKEY \
test.xxx.xxx

I could not test IPv6 since I do not have a valid IPv6 address on my test network.

@twoellert
Copy link

Additional info to my last comment. I was now also able to test the changes using IPv6 addresses.

With the changes I mentioned in my previous comment both IPv4 and IPv6 work as expected.

@bringha1
Copy link

This sounds very encouraging -

One question: did also the 'Fritzbox Model' work properly by updating ipv4 and ipv6 simultaneously with one API call? Or is it either or?

@twoellert
Copy link

@bringha1 I did not try via fritzbox but via the cmd options for ipv4 and ipv6 grabbing the IPs from our OPNSense API. If it helps I can try the fritzbox model at home with my 7490 for ipv4 and ipv6 and let you know how it goes.

@bringha1
Copy link

Sorry perhaps I generated a misunderstanding: I tried this already with a fritzbox and the update of ipv4 and ipv6 in ONE API call as described in the Ionos docs works. However I could not yet reproduce it without a fritzbox by using the mentioned URL format
https://ipv4.api.hosting.ionos.com/dns/v1/dyndns?q=NDFjZmM3YmVjYjQzNDRhMTkxMzliZDAwYzA2OGU3NzEuU2FvNlhuR2U4UmtxNGdiQzlMN19TLWpZanM4LWZBdGsxX2Ixa2FFUmRFWUp4Z1pmR3NWOVFpUjZYZGQ5TTZ5QjBIZkxSRFAyN2lzeHhCRWNuNVpSU0E&ipv4=&ipv6=
eg directly with OPNsense or a Linux box yet. I assume that the ddclient Ionos logic intends to use the suggested URL format ?!

@LenardHess LenardHess added enhancement New feature or request provider Adds, fixes or removes a provider. not-in-this-release Won't yet be handled in the upcoming release labels Aug 12, 2023
@twoellert
Copy link

twoellert commented Aug 12, 2023

@bringha1 Here are the steps I did when I tested ddclient with the new IONOS modifcations, perhaps it helps on your end to reproduce it:

  1. I assume you already have an API key for the IONOS DNS name you want to update
  2. I installed an Ubuntu 22.04.3 LTS VM to test ddclient on
  3. I enabled API access on my office OPNSense for a test user (just did an all access to API to ease the testing)
  4. I cloned ddclient from the feature_provider_ionos branch from this github repository
  5. I made the modification to ddclient.in in line 5865 as described above, changing POST to GET
  6. I built and install ddclient on this Ubuntu VM
  7. I created a script /etc/ddclient/getipv4.sh
curl -s -k -u "OpnSenseAPIKey":"OpnSenseAPISecret" https://OPNSENSE-IP/api/diagnostics/interface/getinterfaceconfig | jq -r ".pppoe0.ipv4[0].ipaddr"
  1. Created a script /etc/ddclient/getipv6.sh
curl -s -k -u "OpnSenseAPIKey":"OpnSenseAPISecret" https://OPNSENSE-IP/api/diagnostics/interface/getinterfaceconfig | jq -r ".pppoe0.ipv6[0].ipaddr"

Depending on your setup the interfacename pppoe0 on the opnsense might be different. Basically when I call these two scripts they print the ipv4 respectively ipv6 address to the command line which the opnsense has at the moment.

  1. I edited the default /etc/ddclient/ddclient.conf:
daemon=300                              # check every 300 seconds
syslog=yes                              # log update msgs to syslog
mail=root                               # mail all msgs to root
mail-failure=root               # mail failed update msgs to root
pid=/var/run/ddclient.pid               # record PID in file.
ssl=yes 

usev4=cmdv4
usev6=cmdv6
cmdv4='/etc/ddclient/getipv4.sh'
cmdv6='/etc/ddclient/getipv6.sh'

protocol=ionos, \
password=MyIONOSAPIKEY \
test.xxx.xxx
  1. I then ran ddclient manually in the command line:
/usr/bin/ddclient -daemon=0 -debug -verbose -noquiet

Lower part of the log output if it helps with the private data omitted:

DEBUG:    get_ipv4: using (cmdv4, /etc/ddclient/getipv4.sh) reports MYIPV4IP
DEBUG:    get_ipv6: using (cmdv6, /etc/ddclient/getipv6.sh) reports MYIPV6IP
DEBUG:
DEBUG:    nic_ionos_update --------------------
INFO:     test.xxx.xxx -- Setting IP address.
DEBUG:    proxy    = <undefined>
DEBUG:    protocol = https
DEBUG:    server   = ipv4.api.hosting.ionos.com
DEBUG:    url      = dns/v1/dyndns?<redacted>
DEBUG:    ip ver   = 4
SENDING:  Curl system cmd to https://ipv4.api.hosting.ionos.com
SENDING:  silent
SENDING:  include
SENDING:  ipv4
SENDING:  user-agent="ddclient/3.11.0"
SENDING:  connect-timeout=120
SENDING:  max-time=120
SENDING:  request=GET
SENDING:  url="https://ipv4.api.hosting.ionos.com/dns/v1/dyndns?q=MyIONOSAPIKey&ipv4=MyIPv4IP&ipv6=MyIPv6IP"
DEBUG:    CURL: \/usr\/bin\/curl
DEBUG:    CURL Tempfile: /tmp/ddclient_5YC1RT9iLp
RECEIVE:  HTTP/2 200
RECEIVE:  date: Sat, 12 Aug 2023 16:13:14 GMT
RECEIVE:  content-length: 0
RECEIVE:  set-cookie: DPX=xxx; Path=/; Expires=Sat, 12-Aug-23 17:13:13 GMT; HttpOnly; Secure; SameSite=Lax
RECEIVE:  vary: Origin
RECEIVE:  vary: Access-Control-Request-Method
RECEIVE:  vary: Access-Control-Request-Headers
RECEIVE:  cache-control: no-cache, no-store, max-age=0, must-revalidate
RECEIVE:  pragma: no-cache
RECEIVE:  expires: 0
RECEIVE:  x-content-type-options: nosniff
RECEIVE:  x-frame-options: DENY
RECEIVE:  x-xss-protection: 1 ; mode=block
RECEIVE:  referrer-policy: no-referrer
RECEIVE:  x-b3-traceid: 84c82260a58f5f3e
RECEIVE:  x-kong-upstream-latency: 452
RECEIVE:  x-kong-proxy-latency: 1
RECEIVE:  via: kong/3.0.0
RECEIVE:  set-cookie: xxx; path=/; HttpOnly; Secure; SameSite=None
RECEIVE:  vary: Origin
RECEIVE:  access-control-allow-origin: *
RECEIVE:
SUCCESS:  test.xxx.xxx -- Updated successfully.

It updated both Ipv4 and Ipv6 addresses on my test domain name.

@TinfoilSubmarine
Copy link
Contributor

  1. I created a script /etc/ddclient/getipv4.sh
curl -s -k -u "OpnSenseAPIKey":"OpnSenseAPISecret" https://OPNSENSE-IP/api/diagnostics/interface/getinterfaceconfig | jq -r ".pppoe0.ipv4[0].ipaddr"
  1. Created a script /etc/ddclient/getipv6.sh
curl -s -k -u "OpnSenseAPIKey":"OpnSenseAPISecret" https://OPNSENSE-IP/api/diagnostics/interface/getinterfaceconfig | jq -r ".pppoe0.ipv6[0].ipaddr"

Depending on your setup the interfacename pppoe0 on the opnsense might be different. Basically when I call these two scripts they print the ipv4 respectively ipv6 address to the command line which the opnsense has at the moment.

Hi, sorry to go a little off-topic here, but I wanted to ask you if you would be interested in trying to implement this OpnSense IP retrieval as part of ddclient? I've been looking into how to get it from the API for the past few days and saw that you have a working method, albeit with curl/shell instead of perl.

@LenardHess
Copy link
Contributor Author

  1. I created a script /etc/ddclient/getipv4.sh
curl -s -k -u "OpnSenseAPIKey":"OpnSenseAPISecret" https://OPNSENSE-IP/api/diagnostics/interface/getinterfaceconfig | jq -r ".pppoe0.ipv4[0].ipaddr"
  1. Created a script /etc/ddclient/getipv6.sh
curl -s -k -u "OpnSenseAPIKey":"OpnSenseAPISecret" https://OPNSENSE-IP/api/diagnostics/interface/getinterfaceconfig | jq -r ".pppoe0.ipv6[0].ipaddr"

Depending on your setup the interfacename pppoe0 on the opnsense might be different. Basically when I call these two scripts they print the ipv4 respectively ipv6 address to the command line which the opnsense has at the moment.

Hi, sorry to go a little off-topic here, but I wanted to ask you if you would be interested in trying to implement this OpnSense IP retrieval as part of ddclient? I've been looking into how to get it from the API for the past few days and saw that you have a working method, albeit with curl/shell instead of perl.

This makes sense as a "sample*" script, similar to i.e the Fritzbox one. Feel free to submit such a script as a separate pull request. (It'll most likely also wait until after v3.11.1)

@bringha1
Copy link

Not sure whether on OPNsense the API calls-scripts to get the ip addresses are required. This information is cached on the OPNsense systems in /tmp, eg /tmp/pppoe_oldip or /tmp/pppoe_oldipv6. These files are afaik updated every time when an ip address is getting updated on WAN.

@TinfoilSubmarine
Copy link
Contributor

Not sure whether on OPNsense the API calls-scripts to get the ip addresses are required. This information is cached on the OPNsense systems in /tmp, eg /tmp/pppoe_oldip or /tmp/pppoe_oldipv6. These files are afaik updated every time when an ip address is getting updated on WAN.

Still useful to include for those of us running ddclient on other systems :)

@twoellert
Copy link

twoellert commented Aug 16, 2023

I can take a look on the implementation side of things for opnsense. Until opnsense updates the ddclient plugin to your latest version I am sure a lot of people are interested in that. I am anyway not totally sure what opnsense plans there since they also provide a selectable backend for ddclient which has different providers. I assume they implement that on their own.

Though they were also somewhat confused when ddclient looked like end of life, though I assume this problem has been fixed. Thanks for you guys taking over the maintenance on ddclient :)

This provider implementation uses sparsely documented details of the
their updating mechanism. The only reference to passing in IP addresses
via GET parameters I could see was in the german version of the dynamic
DNS tutorial, where they showed it as part of a FRITZ!Box setup example.
@LenardHess LenardHess force-pushed the feature_provider_ionos branch from ddab411 to c978d9b Compare October 15, 2023 11:07
@furchtlos76
Copy link

Is ionos or other providers that just have a url and nothing more implemented now or not? Sorry could not find any info and this pull request ist work in progress?

@LenardHess
Copy link
Contributor Author

No genetic URL-only provider is implemented currently, no. Until now the focus was on fixing outstanding 3.10 issues and not new features. After new years I will be able to continue on this WIP implementation for IONOS

@rhansen rhansen removed the not-in-this-release Won't yet be handled in the upcoming release label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request provider Adds, fixes or removes a provider.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants