plugins icon indicating copy to clipboard operation
plugins copied to clipboard

dns/bind: allow to specify primaryip's port for secondary zone

Open loopway opened this issue 11 months ago • 6 comments

Closes: #4444

Notes on proposed solution

Bind/Domain.xml:

  • change field type to CSVListField, adopted from net/haproxy HAProxy.xml to allow port specification

Bind/named.conf

  • adjust jinja2 template instead of introducing new fields to avoid have to deal with config migrations of previous opnsense versions
  • if specifying a port for a ipv6 address the following notion has to be used: [address]:port (https://en.wikipedia.org/wiki/IPv6#Address_representation)
  • using negative lookbehind in regular expression to avoid matching ipv6 addresses without port
  • using multiple lookbehind regular expressions since quantifiers are not allowed and ipv6 addresses can be shortened

loopway avatar Jan 05 '25 01:01 loopway

As discussed... https://github.com/opnsense/core/commit/153d3cc267

fichtner avatar Jul 02 '25 14:07 fichtner

@loopway do you know if you'll get time to re-evaluate your PR?

zndrr avatar Aug 03 '25 00:08 zndrr

I'll be happy to re-evaluate my PR. I would just need a hint from @fichtner what to use instead of the regex_replace (https://github.com/opnsense/plugins/issues/4444#issuecomment-3112540194).

loopway avatar Aug 20 '25 14:08 loopway

It's more or less the reverse of https://github.com/opnsense/core/commit/8db4d8dc330 which is about to be added, but I think the use case is too narrow for this as most support the format supplied by IPPortField. If you update the PR with the model change I'll take a look what the templating could do. For testing the regex is fine now.

fichtner avatar Aug 20 '25 15:08 fichtner

I've changed the field type to IPPortField and rebased my branch.

loopway avatar Aug 22 '25 23:08 loopway

@loopway Could you add the same changes to forwardserver?

phprus avatar Nov 03 '25 20:11 phprus

I think we're almost there but the inplace regex_replace() should not be there. We can unwind using local variables for better readability/maintainability.

Cheers, Franco

fichtner avatar Dec 17 '25 08:12 fichtner