aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2014-02-19 10:23:28 +0100
committerErmal Luçi <eri@pfsense.org>2014-02-19 10:23:28 +0100
commita94907305151b382a65096d42cc6be0c68b16f75 (patch)
tree3123fcbec47fbfbcecab498134e4e6286b6d4206
parent264f50db69f448739f7cbce8a15dd1a9af718837 (diff)
parenta519779703195b8f16b86295ca047b01c8c8eebb (diff)
downloadpfsense-packages-a94907305151b382a65096d42cc6be0c68b16f75.tar.gz
pfsense-packages-a94907305151b382a65096d42cc6be0c68b16f75.tar.bz2
pfsense-packages-a94907305151b382a65096d42cc6be0c68b16f75.zip
Merge pull request #584 from mbfgit/staticmap-reverse
Update reverse zone for dhcp static map
-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']!=""){