fix: set listen IP in _action_fix_snmp so snmpd binds to management IF
Without an explicit listen address, os-net-snmp on OPNsense may not
respond on non-loopback interfaces. The fix sets
listen = {self.hostname: {"selected": 1}} which is always the
management IP used to reach this device in netOrk.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
9f9fafb6f5
commit
629822c055
@@ -1579,6 +1579,12 @@ class OPNsenseDriver(FirewallDriver):
|
||||
lines.append("[install] os-net-snmp already installed — skipping reinstall")
|
||||
|
||||
# 2. Configure SNMP
|
||||
# The listen field must contain the management IP so that snmpd binds
|
||||
# to the correct interface. Without it snmpd may not respond on any
|
||||
# non-loopback address.
|
||||
# The API expects {"<ip>": {"selected": 1}} — we use self.hostname
|
||||
# which is always the device's management IP in netOrk.
|
||||
listen_val: dict = {self.hostname: {"selected": 1}}
|
||||
try:
|
||||
self._post("/api/netsnmp/general/set", {
|
||||
"general": {
|
||||
@@ -1588,9 +1594,10 @@ class OPNsenseDriver(FirewallDriver):
|
||||
"location": "Managed by netOrk",
|
||||
"sysobjid": "",
|
||||
"bindip": "",
|
||||
"listen": listen_val,
|
||||
}
|
||||
})
|
||||
lines.append("[config] SNMP enabled with community 'public'.")
|
||||
lines.append(f"[config] SNMP enabled with community 'public', listen={self.hostname}.")
|
||||
except Exception as exc:
|
||||
logger.debug("SNMP config failed: %s", exc)
|
||||
lines.append(f"[config] error: {exc}")
|
||||
|
||||
Reference in New Issue
Block a user