aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormbfgit <martinf@gmail.com>2014-02-03 01:17:25 +0000
committermbfgit <martinf@gmail.com>2014-02-03 01:17:25 +0000
commita519779703195b8f16b86295ca047b01c8c8eebb (patch)
treea4cb03def734a11be7325bff058f08fdc5574b56
parent2c6efc978d2fc988ff8fafbf59bcdc6050a3695d (diff)
downloadpfsense-packages-a519779703195b8f16b86295ca047b01c8c8eebb.tar.gz
pfsense-packages-a519779703195b8f16b86295ca047b01c8c8eebb.tar.bz2
pfsense-packages-a519779703195b8f16b86295ca047b01c8c8eebb.zip
Update reverse zone for dhcp static map
Addresses Bug #3323, add PTR records for reverse zone.
-rw-r--r--config/bind/bind.inc27
1 files changed, 24 insertions, 3 deletions
diff --git a/config/bind/bind.inc b/config/bind/bind.inc
index ff3728fb..40d626db 100644
--- a/config/bind/bind.inc
+++ b/config/bind/bind.inc
@@ -438,12 +438,33 @@ EOD;
$zone_conf .= "$hostname \t IN $hosttype $hostvalue \t$hostdst\n";
}
- if (($zone[regdhcpstatic] == 'on') && is_array($config['dhcpd'])) {
- foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf)
+ if (($zone[regdhcpstatic] == 'on') && is_array($config['dhcpd'])) {
+ foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf)
if(is_array($dhcpifconf['staticmap']) && isset($dhcpifconf['enable']))
foreach ($dhcpifconf['staticmap'] as $host)
if ($host['ipaddr'] && $host['hostname']) {
- $zone_conf .= "{$host['hostname']}\tIN A\t{$host['ipaddr']}\n";
+ if($zonereverso == "on") {
+ $hostdomain = $dhcpifconf['domain'];
+ if(strlen($hostdomain) == 0) {
+ $hostdomain = $config['system']['domain'];
+ }
+ if(strlen($hostdomain) != 0) {
+ $hostdomain .= '.';
+ }
+ $zoneparts = array_reverse(explode('.',$zonename));
+ $addressparts = explode('.',$host['ipaddr']);
+ $addressstart = 0;
+ while($addressstart < count($zoneparts) && $addressstart < count($addressparts) && $zoneparts[$addressstart] == $addressparts[$addressstart]) {
+ $addressstart++;
+ }
+ $shortaddress='';
+ for($addresspointer = count($addressparts)-1; $addresspointer >= $addressstart; $addresspointer--) {
+ $shortaddress .= (strlen($shortaddress) > 0 ? '.' : '') . $addressparts[$addresspointer];
+ }
+ $zone_conf .= "{$shortaddress}\tIN PTR\t{$host['hostname']}.{$hostdomain}\n";
+ } else {
+ $zone_conf .= "{$host['hostname']}\tIN A\t{$host['ipaddr']}\n";
+ }
}
}
if ($zone['customzonerecords']!=""){