diff options
Diffstat (limited to 'config/bind/bind.inc')
-rw-r--r-- | config/bind/bind.inc | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/config/bind/bind.inc b/config/bind/bind.inc index ff3728fb..1818b225 100644 --- a/config/bind/bind.inc +++ b/config/bind/bind.inc @@ -209,8 +209,9 @@ EOD; $restart_syslog=0; foreach ($syslog_files as $syslog_file){ $syslog_file_data=file_get_contents($syslog_file); - if (!preg_match("/dnsmasq,named,filterdns/",$syslog_file_data)){ + if ( !preg_match("/dnsmasq,named,filterdns/",$syslog_file_data) || !preg_match("/'dnsmasq','named','filterdns'/",$syslog_file_data) ) { $syslog_file_data=preg_replace("/dnsmasq,filterdns/","dnsmasq,named,filterdns",$syslog_file_data); + $syslog_file_data=preg_replace("/'dnsmasq','filterdns'/","'dnsmasq','named','filterdns'",$syslog_file_data); file_put_contents($syslog_file,$syslog_file_data); $restart_syslog++; } @@ -438,12 +439,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']!=""){ |