Project

General

Profile

Actions

Bug #8179

open

Incorrect reverse DNS zone in DHCP server config for non-octet-aligned subnet mask

Added by Alfred Barnat about 4 years ago. Updated over 1 year ago.

Status:
Feedback
Priority:
Normal
Category:
DHCP (IPv4)
Target version:
Start date:
12/10/2017
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
Affected Architecture:

Description

I have a DHCP server running on pfSense 2.4.2 on an interface with subnet 172.24.208.0 and subnet mask 255.255.254.0. Upon configuring dynamic DNS, I saw that regular DNS records were being correctly inserted into my DNS server, but PTR records were not. Near the bottom of /var/dhcpd/etc/dhcpd.conf, I found the following:

zone 0-23.208.24.172.in-addr.arpa {
    primary 127.0.0.1;
}

This should have been:
zone 208-209.24.172.in-addr.arpa {
    primary 127.0.0.1;
}

The code responsible is in /etc/inc/services.inc. I believe I was able to restore correct behavior by replacing the entire switch ($ifcfgsn) statement with the following:

$subnet_mask_bits = 32 - $ifcfgsn;
$start_octet = $subnet_mask_bits >> 3;
$octet_mask_bits = $subnet_mask_bits & 3;
if ($octet_mask_bits) {
    $octet_mask = (1 << $octet_mask_bits) - 1;
    $octet_start = $revsubnet[$start_octet] & ~$octet_mask;
    $revsubnet[$start_octet] = $octet_start . "-" . ($octet_start + $octet_mask);
}

(Please use the above as a reference only; the code could undoubtably be improved.)

Actions

Also available in: Atom PDF