os-bind: BIND is restarted on every interface link-up, including interfaces it does not listen on
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- php
- Domain
- backend, networking
Research direction
Start with dns/bind/src/etc/inc/plugins.inc.d/bind.inc, especially the bind_configure() hook registration and bind_configure_do() arguments; compare the interface-aware Unbound hook behavior described in the report. Use the reproduction steps to trigger link-up on an interface without a BIND listen address and check /var/log/system and the named PID. Done means such link-ups do not restart running BIND, while boot, manual reload, and listen-address link-ups still work.
Written by the indexing model from the issue text.
Description
Important notices
- I have read the contributing guide lines at https://github.com/opnsense/plugins/blob/master/CONTRIBUTING.md
- I have searched the existing issues, open and closed, and I'm convinced that mine is new. (The closest one is #3958, a BIND hang after two quick link changes, closed by the stale bot; it describes a different symptom.)
- The title contains the plugin to which this issue belongs
Describe the bug
Whenever any interface gets a link-up event, BIND is stopped and started again, even if the interface is one BIND does not listen on.
We have two routers joined by a direct cable for pfsync/CARP (a private /24 that is not in BIND's listen addresses). When one router reboots, the other sees that link go down and up about five times. Each link-up runs rc.linkup, then interface_configure(), then the dns plugin hook. os-bind registers that hook as 'dns' => ['bind_configure_do'], so it rebuilds the config and runs a full BIND restart each time. On the router that stayed up, BIND was restarted five or six times within about 30 seconds (about 3 s each), and a monitoring query to it got SERVFAIL in between, so DNS was patchy for the whole network while the other router rebooted.
Since 26.7.9 core passes the interface to the dns hook (core#11083, the Unbound change). Unbound registers the hook as unbound_configure_do:2 and skips interfaces it doesn't care about. os-bind doesn't ask for the interface, so it never sees it. I don't know of a last working version.
To Reproduce
- Bring any interface down and up:
ifconfig <if> down; ifconfig <if> up, or/usr/local/etc/rc.linkup start <if>. - Watch
/var/log/systemforplugins_configure dns (...)andexecute task : bind_configure_do(...). - BIND stops and starts again (the
namedpid changes), whichever interface it was.
Expected behavior
An interface that carries none of BIND's listen addresses should not restart BIND, as with Unbound.
Relevant log files
/var/log/system on the router that stayed up when its peer rebooted: five or six plugins_configure dns (execute task : bind_configure_do(...)) lines within about 30 seconds, each followed by a BIND restart.
Additional context
We tried the same pattern for os-bind: register bind_configure_do:2, and skip the restart when none of the passed interfaces carries an address BIND listens on. BIND still restarts at boot (no interface passed) and starts if it isn't running. Diff below; it applies to current master (bind.inc unchanged since January 2024).
What we tested (HA pair, BIND listening on LAN/VLAN addresses, IPv4 and IPv6). Each case ran three times:
- Before the change, BIND restarted every time on: the pfsync interface (hook only,
rc.linkup, and a realifconfig igc3 down/up, which restarted BIND on both routers); on the second router, an uncabled WAN and a VLAN with a listen address. - After the change, no restart (BIND's pid unchanged, both routers) on: the pfsync interface (hook and
rc.linkup), WAN, a Tailscale interface and an IPv6 tracker interface. Also no restart in 12 observations of a real pfsync link down/up with the change on both routers. - After the change, BIND still restarts for an interface with a listen address (DMZ VLAN, both routers; LAN, WireGuard and a VLAN link-up, second router), when no interface is passed (second router), and it starts when it was stopped beforehand (second router).
- Not tested: a full reboot of the peer with the change in place, and a call with an explicitly empty interface list (core doesn't pass one through
plugins_configure()).
--- a/dns/bind/src/etc/inc/plugins.inc.d/bind.inc
+++ b/dns/bind/src/etc/inc/plugins.inc.d/bind.inc
@@ -36,7 +36,7 @@
function bind_configure()
{
return [
- 'dns' => ['bind_configure_do'],
+ 'dns' => ['bind_configure_do:2'],
];
}
@@ -90,8 +90,44 @@
return [$result];
}
-function bind_configure_do($verbose)
+function bind_match_interface($interface_map)
{
+ if (empty($interface_map)) {
+ /* no interface given (boot, manual reload): restart as before */
+ return true;
+ }
+
+ $model = new \OPNsense\Bind\General();
+ $listen = array_merge(
+ explode(',', (string)$model->listenv4),
+ explode(',', (string)$model->listenv6)
+ );
+
+ foreach (interfaces_addresses($interface_map) as $address) {
+ if (in_array($address['address'], $listen)) {
+ return true;
+ }
+ }
+
+ /*
+ * None of these interfaces carries an address BIND listens on
+ * (wildcard listen addresses are picked up by BIND itself),
+ * so a restart is not needed.
+ */
+ return false;
+}
+
+function bind_configure_do($verbose = false, $interface_map = null)
+{
+ if (!plugins_argument_map($interface_map)) {
+ return;
+ }
+
+ /* try to avoid restarting, but make sure to let it start if it is not running */
+ if (!bind_match_interface($interface_map) && isvalidpid('/var/run/named/pid')) {
+ return;
+ }
+
service_log('Starting BIND...', $verbose);
configd_run('template reload OPNsense/Bind');
Environment
OPNsense 26.7.9 (amd64), os-bind 1.34_4, BIND 9.20.30; two Intel igc-based routers in a CARP/pfsync pair.
AI disclosure: I used Claude (Anthropic), with several different models, to trace the hook path through the core and plugin code and to write and run the tests. I reviewed the result, ran the tests on my own routers, and I'm responsible for the report.
- Dominant language
- PHP
- Stars
- 1.2k
- Forks
- 926
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 25
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from opnsense/plugins
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
opnsense/plugins#5976 · 1 comment ·
Maintainers usually reply within 1 day
-
net/haproxy: IPv6 literal in real server "Source address" generates an invalid `source` directiveOpenincomplete
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
opnsense/plugins#5973 · 1 comment ·
Maintainers usually reply within 1 day
-
[dns/ddclient] Support hiding unused standard fields per service (optional_hiding)Possibly taken @bringha1 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
q-feeds-connector: "error in configd communication" every update when the Unbound DNSBL rebuild takes longer than 120sPossibly taken @mhatipog claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
All issues in opnsense/plugins
Similar issues
-
15.0
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
open-telemetry/opentelemetry-php-distro#176 ·
Maintainers usually reply within 2 days
-
No Code Attached Yet
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
joomla/joomla-cms#48941 ·
Maintainers usually reply within 1 day
-
needs-triage Platform(Default)
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug new
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
moodle-an-hochschulen/moodle-theme_boost_union#1500 ·
Maintainers usually reply within 1 day