Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dns/ddclient: Add support for altering IPv6 addresses in ddclient plugin #4491

Closed
wants to merge 3 commits into from

Conversation

SaarLAN-Pissbeutel
Copy link
Contributor

When using the DynDNS client in combination with IPv6 addresses with a dynamic prefix, it is currently impossible to change the host part of the address to another host in the network. This pull request aims to fix this issue by adding the necessary functionality to the ddclient plugin.

A new field is added to the advanced view, where a partial IPv6 address (the host part) can be added. Validation is performed, so that the user can only enter a valid partial IPv6 address.

When this field is populated and the IP in question is an IPv6 (e.g. by using the "Interface [IPv6]" method), the IP for the DynDNS service will be altered so that the prefix stays and the host part is added.

Should resolve #4466

grafik

grafik

grafik

@AdSchellevis
Copy link
Member

@SaarLAN-Pissbeutel can you offer some examples of the full input and expected output? This feels a bit convoluted, but I don't mind taking a look at the PR if we can make the requirements clear enough.

@SaarLAN-Pissbeutel
Copy link
Contributor Author

@AdSchellevis yes, of course!

I just updated and de-convoluted the code to also include the other web based ip checks.

This PR should help people who receive a dynamic prefix from their provider which changes every now and then and want to update their DynDNS records to resolve another host on the network. The "Dynamic IPv6 Host" alias for firewall rules is very similiar.

A use case would be a service on another machine in the network which should be made available to the internet. In the IPv4 world, having the WAN IP of the OPNsense and NAT is sufficient. For IPv6, the DynDNS updater must either run on the other machine and update the record with its own IP or if OPNsense updates the record with its own IP, NAT has to be used again. With this feature, there is no need to run a lot of DynDNS updaters on other machines while still having the records updated to point to the specific hosts.

@nk404030 has described the scenario in his report #4466.

There are 3 possibilities:

  1. With an IPv4 address, the input is ignored (reflecting the current state of the dyndns plugin)
  2. With an IPv6 address and an empty input, the address is not changed and it will be the IPv6 address of the OPNsense (reflecting the current state of the dyndns plugin)
  3. With an IPv6 address and a 64bit host identifier as input, the host identifier of the initial IPv6 address will be swapped with the entered host identifier (new functionality)

Possible inputs are partial IPv6 addresses (the last 64 bit) according to the regex. Examples would be:

  • ::1
  • :1:2:3:4
  • :1111:2222:3333:4444

How can I help to make the requirements clear enough?

@AdSchellevis
Copy link
Member

ok, I think I understand what you want, so let me rephrase to be sure (in the ipv6 + input case), with ::1:2:3 as input:

  1. the checkip() or selected address offers an ipv6 address (e.g. fdf3:2c26:f4e4::4a31)
  2. We cut the most significant 64 bits from this address (e.g. fdf3:2c26:f4e4::)
  3. The input should contain a 64bit address which will be added as least significant part (results in fdf3:2c26:f4e4::1:2:3)

Ideally we should validate the input data, the ip address split might need some normalization as well, but we can take a look at that later.

@SaarLAN-Pissbeutel
Copy link
Contributor Author

Yes, that's right. We use the existing network identifier (first 64 bits) and swap out the host identifier (last 64 bits) for our custom host.

During my testing, the regex in the DynDNS.xml nicely validated the data and only accepted what ipaddress.ip_address can work with.

The normalization is done with ipaddress.ip_address(ipv6host).exploded which would convert ::1 to :0000:0000:0000:1.

@AdSchellevis
Copy link
Member

you're right, the regex seems to match pretty well. Let me take a look at the rest of the code.

AdSchellevis added a commit that referenced this pull request Jan 22, 2025
* simplify network / host concat a bit
* add try...except for the curl fetch in case the other end doesn't return a valid address
* extend form help text for "Dynamic ipv6 host" a bit
@AdSchellevis
Copy link
Member

@SaarLAN-Pissbeutel I've added a3b405c on top, can you double check if this does the trick? If so, I'll close this PR and merge the adjusted branch.

@SaarLAN-Pissbeutel
Copy link
Contributor Author

@AdSchellevis thanks for the adjustments. Looks good to me and works as intended! Looking forward to see the feature in the stable release 😃

AdSchellevis added a commit that referenced this pull request Jan 23, 2025
…gin (#4497)

* Add support for altering IPv6 addresses in ddclient plugin

* Refactoring of checkip

* dns/ddclient - minor cleanups for #4491

* simplify network / host concat a bit
* add try...except for the curl fetch in case the other end doesn't return a valid address
* extend form help text for "Dynamic ipv6 host" a bit

---------

Co-authored-by: SaarLAN-Pissbeutel <[email protected]>
Co-authored-by: Marc Philippi <[email protected]>
@AdSchellevis
Copy link
Member

@SaarLAN-Pissbeutel thanks for your feedback, merged in 8606b35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

os-ddclient / add option to update other hosts or aliases
2 participants