summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interface-definitions/snmp.xml8
-rwxr-xr-xsrc/conf_mode/snmp.py13
2 files changed, 18 insertions, 3 deletions
diff --git a/interface-definitions/snmp.xml b/interface-definitions/snmp.xml
index bcd5295ee..698fb34a1 100644
--- a/interface-definitions/snmp.xml
+++ b/interface-definitions/snmp.xml
@@ -77,6 +77,14 @@
<tagNode name="listen-address">
<properties>
<help>IP address to listen for incoming SNMP requests</help>
+ <valueHelp>
+ <format>ipv4</format>
+ <description>IPv4 address to listen for incoming SNMP requests</description>
+ </valueHelp>
+ <valueHelp>
+ <format>ipv6</format>
+ <description>IPv6 address to listen for incoming SNMP requests</description>
+ </valueHelp>
<constraint>
<validator name="ipv4-address"/>
<validator name="ipv6-address"/>
diff --git a/src/conf_mode/snmp.py b/src/conf_mode/snmp.py
index d32a9a343..80f3bee8c 100755
--- a/src/conf_mode/snmp.py
+++ b/src/conf_mode/snmp.py
@@ -20,12 +20,12 @@ import sys
import os
import jinja2
+import vyos.version
+import ipaddress
from vyos.config import Config
from vyos import ConfigError
-import vyos.version
-
config_file_client = r'/etc/snmp/snmp.conf'
config_file_daemon = r'/etc/snmp/snmpd.conf'
@@ -92,7 +92,7 @@ SysDescr {{ description }}
{% endif %}
# Listen
-agentaddress unix:/run/snmpd.socket{% for ip in listen_on %},udp:{{ ip.addr }}:{{ ip.port }}{% endfor %}
+agentaddress unix:/run/snmpd.socket{% for ip in listen_on %},{{ ip.prot }}:{{ ip.addr }}:{{ ip.port }}{% endfor %}
# SNMP communities
@@ -172,8 +172,15 @@ def get_config():
if conf.exists('listen-address'):
for addr in conf.list_nodes('listen-address'):
+ prot = "udp"
+ if ipaddress.ip_address(addr).version == 6:
+ # SNMP configuration file requires brackets on IPv6 addresses
+ addr = "[" + addr + "]"
+ prot = "udp6"
+
listen = {
'addr': addr,
+ 'prot': prot,
'port': '161'
}