Mask calculation for SDN subnets question

karypid

Well-Known Member
Mar 7, 2021
41
10
48
48
Hello,

I have set up PowerDNS and have added it in SDN --> Options with success (proxmox can create entries there).

I have come across a problem with the reverse DNS zone calculation used:

- I have a 192.168.43.0/24 subnet
- I expect proxmox to use 43.168.192.in-addr.arpa
- Instead, proxmox when it creates the reverse DNS mapping, it calculates 192.168.0.0/16 as the subnet incorrectly and updates 168.192.in-addr.arpa

Now I am not a Perl dev, but I tracked down the calculation to this this file which I have never modified:
Perl:
root@goliath:~# grep -A 22 "get_reversedns_zone" /usr/share/perl5/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
sub get_reversedns_zone {
    my ($class, $plugin_config, $subnetid, $subnet, $ip) = @_;

    my $cidr = $subnet->{cidr};
    my $mask = $subnet->{mask};

    my $zone = "";

    if (Net::IP::ip_is_ipv4($ip)) {
        my ($ipblock1, $ipblock2, $ipblock3, $ipblock4) = split(/\./, $ip);

        my $ipv4 = NetAddr::IP->new($cidr);
        #private addresse #powerdns built-in private zone : serve-rfc1918
        if ($ipv4->is_rfc1918()) {
            if ($ipblock1 == 192) {
                $zone = "168.192.in-addr.arpa.";
            } elsif ($ipblock1 == 172) {
                $zone = "16-31.172.in-addr.arpa.";
            } elsif ($ipblock1 == 10) {
                $zone = "10.in-addr.arpa.";
            }

        } else {


root@goliath:~# dpkg -S /usr/share/perl5/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
libpve-network-perl: /usr/share/perl5/PVE/Network/SDN/Dns/PowerdnsPlugin.pm

If I haven't misunderstood, this calculation is hard-coding specific zone names. I would expect the ipblock[1-4] variables to be used to calculate the zone.

Is this a bug or is it intentional?

Are we supposed to create these specific zones in powerdns for things to work? (I have not found something in the docs unless I missed it).
 
I have been running using 168.192.in-addr.arpa since it seems to be "what just works out of the box". Another thing I noticed is that if you go to SDN --> IPAM and remove an IP mapping:

- the reverse mapping is (correctly) removed from powerdns
- the forward mapping remains in powerdns and keeps resolving to the removed IP

This seems like an omission?