diff options
| author | Matthieu Pignolet <m@mpgn.dev> | 2025-02-27 13:02:27 +0400 |
|---|---|---|
| committer | Thomas Lamprecht <t.lamprecht@proxmox.com> | 2025-03-25 19:30:57 +0100 |
| commit | 2fd0ad83d3cc043092d54d104cc5df40ad062b3a (patch) | |
| tree | 5a8b68c545540f82d612e20b4ed051b5bcb31510 | |
| parent | a77f0c21ca9b418e6e5bdbd46ba6974d02112702 (diff) | |
dns: powerdns: correctly handle different records types (A / AAAA)
This fixes an issue with dual stacking, when using a zone with both a
IPv4 and IPv6 subnet and the same DNS suffix, pve-network will try to
set both DNS records (type A and AAAA) in the same powerdns rrset,
causing an API error, and effectively causing no forward DNS records
being created.
This change edits the `get_zone_rrset` function so that it takes the
DNS record type into account.
Signed-off-by: Matthieu Pignolet <m@mpgn.dev>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
[TL: wrap commit message]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
| -rw-r--r-- | src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm b/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm index 15afb4a..aad8b6f 100644 --- a/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm +++ b/src/PVE/Network/SDN/Dns/PowerdnsPlugin.pm @@ -66,7 +66,7 @@ sub add_a_record { my $fqdn = $hostname.".".$zone."."; my $zonecontent = get_zone_content($plugin_config, $zone); - my $existing_rrset = get_zone_rrset($zonecontent, $fqdn); + my $existing_rrset = get_zone_rrset($zonecontent, $fqdn, $type); my $final_records = []; for my $record (@{$existing_rrset->{records}}) { @@ -136,7 +136,7 @@ sub del_a_record { my $type = Net::IP::ip_is_ipv6($ip) ? "AAAA" : "A"; my $zonecontent = get_zone_content($plugin_config, $zone); - my $existing_rrset = get_zone_rrset($zonecontent, $fqdn); + my $existing_rrset = get_zone_rrset($zonecontent, $fqdn, $type); my $final_records = [ grep { $_->{content} ne $ip } $existing_rrset->{records}->@* ]; my $final_records_size = scalar($final_records->@*); @@ -262,10 +262,10 @@ sub get_zone_content { } sub get_zone_rrset { - my ($zonecontent, $name) = @_; + my ($zonecontent, $name, $type) = @_; for my $rrset (@{$zonecontent->{rrsets}}) { - return $rrset if $rrset->{name} eq $name; + return $rrset if $rrset->{name} eq $name and ($rrset->{type} eq $type); } return; # not found } |
