From a69fa0d77dc17882f01e3488a955e81b7cb4143f Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Wed, 29 Mar 2023 08:50:12 +0200 Subject: [PATCH] dns/bind: refine previous It was decided we only want the 'ports' trick for DNS so make sure the prerequistes for it match the reality of the setup. This was we can also extend the validation of the DNS port like we are going to do for Unbound to ensure a functional DNS setup when multiple DNS servers are being used on the same box. --- dns/bind/pkg-descr | 1 + dns/bind/src/etc/inc/plugins.inc.d/bind.inc | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dns/bind/pkg-descr b/dns/bind/pkg-descr index 31cc0ebc0..344006191 100644 --- a/dns/bind/pkg-descr +++ b/dns/bind/pkg-descr @@ -14,6 +14,7 @@ Plugin Changelog * Allow multiple ACLs to be selected for Transfers/Queries (contributed by Robbert Rijkse) * Rename Master/Slave to Primary/Secondary (contributed by Robbert Rijkse) +* Add necessary hooks to allow the plugin to be used as a standalone core DNS server 1.25 diff --git a/dns/bind/src/etc/inc/plugins.inc.d/bind.inc b/dns/bind/src/etc/inc/plugins.inc.d/bind.inc index 12ef025c5..a435fac63 100644 --- a/dns/bind/src/etc/inc/plugins.inc.d/bind.inc +++ b/dns/bind/src/etc/inc/plugins.inc.d/bind.inc @@ -49,9 +49,22 @@ function bind_services() $model = new \OPNsense\Bind\General(); + /* DNS service is eligable for core use when both 127.0.0.1 and ::1 are set */ + $localhost4 = false; + $localhost6 = false; + + foreach (explode(',', (string)$model->listenv4) as $addr) { + $localhost4 |= $addr === '127.0.0.1'; + } + + foreach (explode(',', (string)$model->listenv6) as $addr) { + $localhost6 |= $addr === '::1'; + } + $services[] = [ + /* the port may still be something other than 53, but it's safe to register a conflict for it */ + 'ports' => ($localhost4 && $localhost6 ? [(string)$model->port] : []), 'description' => gettext('BIND Daemon'), - 'ports' => [(string)$model->port], 'configd' => [ 'restart' => ['bind restart'], 'start' => ['bind start'],