summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2013-05-22 16:01:46 -0400
committerjim-p <jimp@pfsense.org>2013-05-22 16:01:46 -0400
commita4f7c378f126fedaf712b8098e6836c208727ef4 (patch)
treeffeed12595467d75c11f1e5ef011a23dce8cd6b1
parent0b03b89f9d945fce28d1c474a2638f02224d018a (diff)
downloadpfsense-a4f7c378f126fedaf712b8098e6836c208727ef4.zip
pfsense-a4f7c378f126fedaf712b8098e6836c208727ef4.tar.gz
Unbreak Dynamic DNS updates from DHCP, ISC changed the config layout to require zone declarations, and the ddns-update-style directive only works globally.
-rw-r--r--etc/inc/services.inc51
1 files changed, 47 insertions, 4 deletions
diff --git a/etc/inc/services.inc b/etc/inc/services.inc
index 9d6b685..b46b18f 100644
--- a/etc/inc/services.inc
+++ b/etc/inc/services.inc
@@ -116,6 +116,9 @@ function services_dhcpd_configure() {
return 1;
}
+ $need_ddns_updates = false;
+ $ddns_zones = array();
+
$custoptions = "";
foreach ($dhcpdcfg as $dhcpif => $dhcpifconf) {
if(is_array($dhcpifconf['numberoptions']) && is_array($dhcpifconf['numberoptions']['item'])) {
@@ -138,7 +141,6 @@ option domain-search-list code 119 = text;
default-lease-time 7200;
max-lease-time 86400;
log-facility local7;
-ddns-update-style none;
one-lease-per-client true;
deny duplicates;
ping-check true;
@@ -158,7 +160,6 @@ EOD;
*/
$dhcpnum = 0;
foreach ($dhcpdcfg as $dhcpif => $dhcpifconf) {
-
interfaces_staticarp_configure($dhcpif);
if (!isset($dhcpifconf['enable']))
@@ -218,7 +219,7 @@ EOPP;
$dhcpnum = 0;
foreach ($dhcpdcfg as $dhcpif => $dhcpifconf) {
-
+ $newzone = array();
$ifcfg = $config['interfaces'][$dhcpif];
if (!isset($dhcpifconf['enable']) || !isset($Iflist[$dhcpif]))
@@ -246,18 +247,36 @@ EOPP;
}
if (isset($dhcpifconf['ddnsupdate'])) {
+ $need_ddns_updates = true;
+ $newzone = array();
if($dhcpifconf['ddnsdomain'] <> "") {
+ $newzone['domain-name'] = $dhcpifconf['ddnsdomain'];
$dnscfg .= " ddns-domainname \"{$dhcpifconf['ddnsdomain']}\";\n";
+ } else {
+ $newzone['domain-name'] = $config['system']['domain'];
+ }
+ $revsubnet = explode(".", $subnet);
+ $revsubnet = array_reverse($revsubnet);
+ foreach ($revsubnet as $octet) {
+ if ($octet != "0")
+ break;
+ array_shift($revsubnet);
}
- $dnscfg .= " ddns-update-style interim;\n";
+ $newzone['ptr-domain'] = implode(".", $revsubnet) . ".in-addr.arpa";
}
if (is_array($dhcpifconf['dnsserver']) && ($dhcpifconf['dnsserver'][0])) {
$dnscfg .= " option domain-name-servers " . join(",", $dhcpifconf['dnsserver']) . ";";
+ if ($newzone['domain-name'])
+ $newzone['dns-servers'] = $dhcpifconf['dnsserver'];
} else if (isset($config['dnsmasq']['enable'])) {
$dnscfg .= " option domain-name-servers {$ifcfgip};";
+ if ($newzone['domain-name'] && is_array($syscfg['dnsserver']) && ($syscfg['dnsserver'][0]))
+ $newzone['dns-servers'] = $syscfg['dnsserver'];
} else if (is_array($syscfg['dnsserver']) && ($syscfg['dnsserver'][0])) {
$dnscfg .= " option domain-name-servers " . join(",", $syscfg['dnsserver']) . ";";
+ if ($newzone['domain-name'])
+ $newzone['dns-servers'] = $syscfg['dnsserver'];
}
$dhcpdconf .= "subnet {$subnet} netmask {$subnetmask} {\n";
@@ -375,6 +394,30 @@ EOD;
}
$dhcpdifs[] = get_real_interface($dhcpif);
+ if ($newzone['domain-name'])
+ $ddns_zones[] = $newzone;
+ }
+
+ if ($need_ddns_updates) {
+ $dhcpdconf .= "ddns-update-style interim;\n";
+ if (is_array($ddns_zones)) {
+ foreach ($ddns_zones as $zone) {
+ if (!is_array($zone) || empty($zone) || !is_array($zone['dns-servers']))
+ continue;
+ $primary = $zone['dns-servers'][0];
+ $secondary = empty($zone['dns-servers'][1]) ? "" : $zone['dns-servers'][1];
+ $dhcpdconf .= "zone {$zone['domain-name']} {\n";
+ $dhcpdconf .= " primary {$primary};\n";
+ if ($secondary)
+ $dhcpdconf .= " secondary {$secondary};\n";
+ $dhcpdconf .= "}\n";
+ $dhcpdconf .= "zone {$zone['ptr-domain']} {\n";
+ $dhcpdconf .= " primary {$primary};\n";
+ if ($secondary)
+ $dhcpdconf .= " secondary {$secondary};\n";
+ $dhcpdconf .= "}\n";
+ }
+ }
}
fwrite($fd, $dhcpdconf);
OpenPOWER on IntegriCloud