Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T5340: snmp: add checks while configuring snmp listen-address with an… #2072

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

nicolas-fort
Copy link
Contributor

…d without vrf

Change Summary

Add checks for snmp configuration commands.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Component(s) name

snmp

Proposed changes

Check listen-address parameter and vrf configuration, to avoid wrong configuration

How to test

Example 1

vyos@SNMP# run show config comm | grep "address\|snmp\|vrf"
set interfaces ethernet eth0 address 'dhcp'
set interfaces ethernet eth1 address '198.51.100.1/24'
set interfaces ethernet eth1 vrf 'MGMT'
set interfaces ethernet eth2 address '192.0.2.1/24'
set service ntp allow-client address '0.0.0.0/0'
set service ntp allow-client address '::/0'
set vrf name MGMT table '101'
[edit]
vyos@SNMP# set service snmp listen-address 198.51.100.1 
[edit]
vyos@SNMP# commit
[ service snmp ]
SNMP listen address "198.51.100.1" not configured in default vrf!

[[service snmp]] failed
Commit failed
[edit]
vyos@SNMP# set service snmp vrf MGMT 
[edit]
vyos@SNMP# commit
[edit]
vyos@SNMP# sudo netstat -putane | grep 161
udp        0      0 127.0.0.1:161           0.0.0.0:*                           0          16584      3039/snmpd          
udp        0      0 198.51.100.1:161        0.0.0.0:*                           0          16583      3039/snmpd          
udp6       0      0 ::1:161                 :::*                                0          16585      3039/snmpd          
[edit]
vyos@SNMP# 

Example2:

vyos@SNMP# run show config comm | grep "address\|snmp\|vrf"
set interfaces ethernet eth0 address 'dhcp'
set interfaces ethernet eth1 address '198.51.100.1/24'
set interfaces ethernet eth1 vrf 'MGMT'
set interfaces ethernet eth2 address '192.0.2.1/24'
set service ntp allow-client address '0.0.0.0/0'
set service ntp allow-client address '::/0'
set vrf name MGMT table '101'
[edit]
vyos@SNMP# set service snmp vrf MGMT 
[edit]
vyos@SNMP# set service snmp listen-address 192.0.2.1 
[edit]
vyos@SNMP# commit
[ service snmp ]
SNMP listen address "192.0.2.1" not configured in vrf "MGMT"!

[[service snmp]] failed
Commit failed
[edit]
vyos@SNMP# del service snmp vrf 
[edit]
vyos@SNMP# commit
[edit]
vyos@SNMP# sudo netstat -putane | grep 161
udp        0      0 127.0.0.1:161           0.0.0.0:*                           0          26344      3719/snmpd          
udp        0      0 192.0.2.1:161           0.0.0.0:*                           0          26343      3719/snmpd          
udp6       0      0 ::1:161                 :::*                                0          26345      3719/snmpd          
[edit]
vyos@SNMP# 

Example 3:

vyos@SNMP# run show config comm | grep "address\|snmp\|vrf"
set interfaces ethernet eth0 address 'dhcp'
set interfaces ethernet eth1 address '198.51.100.1/24'
set interfaces ethernet eth1 vrf 'MGMT'
set interfaces ethernet eth2 address '192.0.2.1/24'
set service ntp allow-client address '0.0.0.0/0'
set service ntp allow-client address '::/0'
set vrf name MGMT table '101'
[edit]
vyos@SNMP# set service snmp listen-address 198.51.100.1 
[edit]
vyos@SNMP# set service snmp listen-address 192.0.2.1 
[edit]
vyos@SNMP# commit
[ service snmp ]
SNMP listen address "198.51.100.1" not configured in default vrf!

[[service snmp]] failed
Commit failed
[edit]
vyos@SNMP# 

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

@vyosbot vyosbot requested review from a team, dmbaturin, sarthurdev, zdc, jestabro, sever-sever and c-po and removed request for a team July 5, 2023 12:46
@c-po c-po merged commit 67cb7e4 into vyos:current Jul 6, 2023
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants