From 83bbbdc238bd2c72328115bccd5455c67c4bd376 Mon Sep 17 00:00:00 2001 From: Stuart Wyatt Date: Thu, 9 Apr 2015 11:18:00 -0700 Subject: BIND - add support for multiple views per zone configuration Often a zone configuration can be identical for LAN/local and WAN/pulic views, especially when using NAT reflection. This change allows those zones to only be entered once in the configuration and then applied to both the local and public views. The change converts the zone's 'view' field from a single selection to an array multiple selection. Since an old value of 'local' is the same as an array value with only one element for 'local', this change is backwards compatible with existing configurations. For that reason, I'm leaving the field name as 'view' rather than changing it to 'views' When the zones are being added to the view clause, it will now check to see if the view is in the zone's view list rather than checking to see if it is a simple match before including the zone in the view. By setting the old varible $zoneview to the matching view from the list, the existing code needs very little change. --- config/bind/bind.inc | 11 +++++++---- config/bind/bind_zones.xml | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'config') diff --git a/config/bind/bind.inc b/config/bind/bind.inc index 4d579689..d5af73b6 100644 --- a/config/bind/bind.inc +++ b/config/bind/bind.inc @@ -346,7 +346,7 @@ EOD; $custom_root_zone = true; } $zonetype = $zone['type']; - $zoneview = $zone['view']; + $zoneviewlist = explode(',', $zone['view']); $zonecustom = base64_decode($zone['custom']); $zoneipslave = $zone['slaveip']; $zoneforwarders = $zone['forwarders']; @@ -358,8 +358,10 @@ EOD; // Ensure zone view folder exists if ($zonetype != "forward") { - if (!(is_dir(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview"))) { - mkdir(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview", 0755, true); + foreach ($zoneviewlist as $zoneview) { + if (!(is_dir(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview"))) { + mkdir(CHROOT_LOCALBASE."/etc/namedb/$zonetype/$zoneview", 0755, true); + } } } @@ -383,7 +385,8 @@ EOD; $zoneallowtransfer = str_replace(',', '; ', $zone['allowtransfer']); } - if ($zoneview == $viewname) { + if (in_array($viewname, $zoneviewlist)) { + $zoneview = $viewname; // Add zone name if ($zonereverso == "on") { if ($zonereversv6o == "on") { diff --git a/config/bind/bind_zones.xml b/config/bind/bind_zones.xml index 667fd608..17af9538 100644 --- a/config/bind/bind_zones.xml +++ b/config/bind/bind_zones.xml @@ -154,11 +154,13 @@ View view - + select_source name name + + 02 Reverse Zone -- cgit v1.2.3