summaryrefslogtreecommitdiff
path: root/src/conf_mode/snmp.py
diff options
context:
space:
mode:
authorAndras Elso <elso.andras@gmail.com>2020-03-25 11:07:44 +0100
committerAndras Elso <elso.andras@gmail.com>2020-03-25 11:10:00 +0100
commitda3bc26bf94efc04d9e92ff37392e621f6e1a742 (patch)
treea20c15c256a5cfff369d0db49692b20332238cbd /src/conf_mode/snmp.py
parentacb9815216dfe48c9d8684056381d9cd7b10fee0 (diff)
downloadvyos-1x-da3bc26bf94efc04d9e92ff37392e621f6e1a742.tar.gz
vyos-1x-da3bc26bf94efc04d9e92ff37392e621f6e1a742.zip
T2161: Skip ipv6 listen, if it is disabled
Diffstat (limited to 'src/conf_mode/snmp.py')
-rwxr-xr-xsrc/conf_mode/snmp.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/conf_mode/snmp.py b/src/conf_mode/snmp.py
index 812819c59..34832aac1 100755
--- a/src/conf_mode/snmp.py
+++ b/src/conf_mode/snmp.py
@@ -121,7 +121,7 @@ SysDescr {{ description }}
{%- endif %}
# Listen
-agentaddress unix:/run/snmpd.socket{% if listen_on %}{% for li in listen_on %},{{ li }}{% endfor %}{% else %},udp:161,udp6:161{% endif %}
+agentaddress unix:/run/snmpd.socket{% if listen_on %}{% for li in listen_on %},{{ li }}{% endfor %}{% else %},udp:161{% if ipv6_enabled %},udp6:161{% endif %}{% endif %}
# SNMP communities
{%- for c in communities %}
@@ -207,6 +207,7 @@ extend {{ ext.name }} {{ ext.script }}
default_config_data = {
'listen_on': [],
'listen_address': [],
+ 'ipv6_enabled': 'True',
'communities': [],
'smux_peers': [],
'location' : '',
@@ -236,6 +237,9 @@ def get_config():
if not conf.exists('service snmp'):
return None
else:
+ if conf.exists('system ipv6 disable'):
+ snmp['ipv6_enabled'] = False
+
conf.set_level('service snmp')
version_data = get_version_data()
@@ -556,7 +560,7 @@ def verify(snmp):
if is_ipv4(addr):
# example: udp:127.0.0.1:161
listen = 'udp:' + addr + ':' + port
- else:
+ elif snmp['ipv6_enabled']:
# example: udp6:[::1]:161
listen = 'udp6:' + '[' + addr + ']' + ':' + port