dns/bind (os-bind) Adds named.conf.d and appropriate include for custom BIND configurations. (#4775)

* Adds named.conf.d and appropriate include for custom configurations.

* Move 00-README.conf file from template to literal

* Remove log example from custom config README

* Add custom config warning banner.

* Fixed test on glob

* Update dns/bind/src/opnsense/mvc/app/library/OPNsense/System/Status/BindOverrideStatus.php

* Update dns/bind/src/etc/namedb/named.conf.d/00-README.conf

---------

Co-authored-by: Nicholas Card <nick@nicholascard.com>
Co-authored-by: Franco Fichtner <franco@lastsummer.de>
This commit is contained in:
Nick2253
2025-07-02 08:19:53 +02:00
committed by GitHub
co-authored by Nicholas Card Franco Fichtner
parent 13d7441af0
commit fb01f6c448
3 changed files with 66 additions and 0 deletions
@@ -0,0 +1,7 @@
# Custom BIND Configuration Directory
#
# Place your custom BIND directives in .conf files in this directory
# Files are included in alphabetical order
#
# Examples:
# server 192.168.1.100 { edns no; };
@@ -0,0 +1,57 @@
<?php
/*
* Copyright (C) 2025 Nick Card
* Copyright (C) 2025 Deciso B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
namespace OPNsense\System\Status;
use OPNsense\System\AbstractStatus;
use OPNsense\System\SystemStatusCode;
class BindOverrideStatus extends AbstractStatus
{
public function __construct()
{
$this->internalPriority = 2;
$this->internalPersistent = true;
$this->internalIsBanner = true;
$this->internalTitle = gettext('BIND config override');
$this->internalScope = [
'/ui/bind/general/index'
];
}
public function collectStatus()
{
if (count(glob('/usr/local/etc/namedb/named.conf.d/*'))>1) {
$this->internalMessage = gettext(
'The configuration contains manual overwrites, these may interfere with the settings configured here.'
);
$this->internalStatus = SystemStatusCode::NOTICE;
}
}
}
@@ -112,6 +112,8 @@ controls {
};
{% endif %}
include "/usr/local/etc/namedb/named.conf.d/*.conf";
zone "." { type hint; file "/usr/local/etc/namedb/named.root"; };
zone "localhost" { type primary; file "/usr/local/etc/namedb/primary/localhost-forward.db"; };