summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2018-05-21 19:43:00 +0200
committerChristian Poessinger <christian@poessinger.com>2018-06-04 19:19:29 +0200
commitf12cab5ed3ffeb8a4c34cb874cc05a1cd381ba14 (patch)
tree3939c740271c1788948b1ef454315be57ef52dab /src
parent6ca653e4200f18926a34bb82323931cc71f52e8a (diff)
downloadvyos-1x-f12cab5ed3ffeb8a4c34cb874cc05a1cd381ba14.tar.gz
vyos-1x-f12cab5ed3ffeb8a4c34cb874cc05a1cd381ba14.zip
T654: Support IPv6 configuration for SNMP listen address
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/snmp.py13
1 files changed, 10 insertions, 3 deletions
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'
}