How to configure snmp in community sonic

How to configure snmp in community sonic

SNMP 

Overview 

Simple Network Management Protocol (SNMP) is a widely used application-layer protocol that enables centralized monitoring and management of network devices such as switches, routers, and servers. It supports real-time alerts, performance tracking, and remote configuration, making it essential for network operations in enterprise and data center environments. 

 

Feature Description 

SNMP enables the following capabilities: 

Monitoring 

  • Query device/system information using SNMP GET or GETNEXT 

  • Monitor interface status, traffic statistics, and system uptime 

Configuration (if SET is enabled) 

  • Modify device parameters remotely (requires proper access controls) 

Event Notification 

  • Devices send asynchronous notifications (TRAP/INFORM) to SNMP managers when events like interface state changes occur 

NMS Integration 

  • Compatible with Network Management Systems (e.g., SolarWinds, Zabbix, LibreNMS) 

 

Prerequisites 

Hardware Requirements 

  • SONiC-supported switches (e.g., Edgecore, UfiSpace) 

Software Requirements 

  • Network OS: SONiC.master 

  • SNMP Daemon: snmpd must be installed and running 

Access Requirements 

  • Admin or root access via CLI/GUI 

  • SNMP utilities installed on management host: snmpwalk, snmpget, snmpset, snmptrap. 

 

Topology: 

                                  

 

Configuration Steps 

Note 1: Commands are to be executed in sudo mode  

1. Add SNMP Agent Address 

#syntax 
sudo config snmpagentaddress<add/del> <agent_IP_address> 

 
# Example: 
sudo config snmpagentaddress add 172.27.1.117 

 

2. Add SNMP Community 

sudo config snmp community [add/del] <community> (RO | RW) 

replace the community by the following command. 

sudo config snmp community replace <old_community> <new_commuity> 

 

Example: 

sudo config snmp community add test1 RO 

 

3. Set SNMP Location (optional but recommended) 

sudo config snmp location [add/del/modify] <location> 

Example: 

sudo config snmp location add DC_RACK 

 

4. Set SNMP Contact (optional) 

sudo config snmp contact [add/del/modify] <contact> <contact_email> 

Example: 

 

sudo config snmp contact add joe joe@contoso.com  

 

Verification Steps 

1. Verify SNMP Configuration 

admin@sonic:~$ show runningconfiguration snmp  

Location 

-------------------- 

DC_RACK 

 

SNMP_CONTACT SNMP_CONTACT_EMAIL 

-------------------   --------------------------- 

Joe                                    joe@contoso.com 

Community String Community Type 

-----------------------   ---------------------- 

test1                             RO 

 

User Permission Type Type Auth Type Auth Password Encryption Type Encryption Password 

 
 

2. View SNMP some other info using this command: 

admin@sonic:~$ show snmp ? 

Usage: show [OPTIONS] COMMAND [ARGS]... 

Try "show -h" for help. 

  

Error: Too many matches: snmpagentaddress, snmptrap 

 

3. SNMP Walk - Basic System Info on SNMP collector 

root@sonic:/#  snmpwalk -v2c -c test1 172.27.1.117 .1.3.6.1.2.1.1 

 
iso.3.6.1.2.1.1.1.0 = STRING: "SONiC Software Version: SONiC.master.838190-21255dffd - HwSku: UFISPACE-S9110-32X - Distribution: Debian 12.9 - Kernel: 6.1.0-22-2-amd64" 

iso.3.6.1.2.1.1.2.0 = OID: iso.3.6.1.4.1.8072.3.2.10 

iso.3.6.1.2.1.1.3.0 = Timeticks: (8473) 0:01:24.73 

iso.3.6.1.2.1.1.4.0 = STRING: "Azure Cloud Switch vteam <linuxnetdev@microsoft.com>" 

iso.3.6.1.2.1.1.5.0 = STRING: "sonic" 

iso.3.6.1.2.1.1.6.0 = STRING: "NotConfigured" 

iso.3.6.1.2.1.1.7.0 = INTEGER: 72 

iso.3.6.1.2.1.1.8.0 = Timeticks: (2) 0:00:00.02 

iso.3.6.1.2.1.1.9.1.2.1 = OID: iso.3.6.1.6.3.10.3.1.1 

iso.3.6.1.2.1.1.9.1.2.2 = OID: iso.3.6.1.6.3.11.3.1.1 

iso.3.6.1.2.1.1.9.1.2.3 = OID: iso.3.6.1.6.3.15.2.1.1 

iso.3.6.1.2.1.1.9.1.2.4 = OID: iso.3.6.1.6.3.1 

iso.3.6.1.2.1.1.9.1.2.5 = OID: iso.3.6.1.6.3.16.2.2.1 

iso.3.6.1.2.1.1.9.1.2.6 = OID: iso.3.6.1.2.1.49 

iso.3.6.1.2.1.1.9.1.2.7 = OID: iso.3.6.1.2.1.50 

iso.3.6.1.2.1.1.9.1.2.8 = OID: iso.3.6.1.6.3.13.3.1.3 

iso.3.6.1.2.1.1.9.1.2.9 = OID: iso.3.6.1.2.1.92 

iso.3.6.1.2.1.1.9.1.3.1 = STRING: "The SNMP Management Architecture MIB." 

iso.3.6.1.2.1.1.9.1.3.2 = STRING: "The MIB for Message Processing and Dispatching." 

iso.3.6.1.2.1.1.9.1.3.3 = STRING: "The management information definitions for the SNMP User-based Security Model." 

iso.3.6.1.2.1.1.9.1.3.4 = STRING: "The MIB module for SNMPv2 entities" 

iso.3.6.1.2.1.1.9.1.3.5 = STRING: "View-based Access Control Model for SNMP." 

iso.3.6.1.2.1.1.9.1.3.6 = STRING: "The MIB module for managing TCP implementations" 

iso.3.6.1.2.1.1.9.1.3.7 = STRING: "The MIB module for managing UDP implementations" 

iso.3.6.1.2.1.1.9.1.3.8 = STRING: "The MIB modules for managing SNMP Notification, plus filtering." 

iso.3.6.1.2.1.1.9.1.3.9 = STRING: "The MIB module for logging SNMP Notifications." 

iso.3.6.1.2.1.1.9.1.4.1 = Timeticks: (1) 0:00:00.01 

iso.3.6.1.2.1.1.9.1.4.2 = Timeticks: (1) 0:00:00.01 

iso.3.6.1.2.1.1.9.1.4.3 = Timeticks: (1) 0:00:00.01 

iso.3.6.1.2.1.1.9.1.4.4 = Timeticks: (1) 0:00:00.01 

iso.3.6.1.2.1.1.9.1.4.5 = Timeticks: (1) 0:00:00.01 

iso.3.6.1.2.1.1.9.1.4.6 = Timeticks: (1) 0:00:00.01 

iso.3.6.1.2.1.1.9.1.4.7 = Timeticks: (1) 0:00:00.01 

iso.3.6.1.2.1.1.9.1.4.8 = Timeticks: (2) 0:00:00.02 

iso.3.6.1.2.1.1.9.1.4.9 = Timeticks: (2) 0:00:00.02 

 

 
4. SNMP Get – SysName 

root@sonic:/#  snmpget -v2c -c test1 172.27.1.117 .1.3.6.1.2.1.1.5.0 
iso.3.6.1.2.1.1.5.0 = STRING: "sonic" 

 

Troubleshooting Tips 

  • Ensure SNMP daemon is running: 

docker exec -it snmp cat /etc/snmp/snmpd.conf 

 

  • Validate that snmp-server view is configured and used in the group 

  • Check firewall rules to ensure SNMP UDP port 161 is open 

  • Use tcpdump to confirm SNMP queries are reaching the device. 

 

SNMPv3 Configuration on SONiC  

Create SNMPv3 User with AuthPriv (secure mode) 

Syntax: 

sudo config snmp user <add|del> <snmp_user><noAuthNoPriv|AuthNoPriv|Priv> <RO|RW> 

                            <MD5|SHA|HMAC-SHA-2> <auth_password> <DES|AES> 

                            <encrypt_password> 

Example 

sudo config snmp user add test1 Priv RO SHA test1234 AES test5678 

 

Validate the user information: 

admin@sonic:~$ show runningconfiguration snmp user 

User    Permission Type    Type    Auth Type    Auth Password    Encryption Type    Encryption Password 

------  -----------------  ------  -----------  ---------------  -----------------  --------------------- 

test1   RO                 Priv    SHA          test1234         AES                test5678 

 

Test SNMPv3 from a Remote Client 

root@sonic:/# snmpwalk -v3 -u test1 -l authPriv -a SHA -A test1234 -x AES -X test5678 172.27.1.117 

iso.3.6.1.2.1.1.1.0 = STRING: "SONiC Software Version: SONiC.master.838190-21255dffd - HwSku: UFISPACE-S9110-32X - Distribution: Debian 12.9 - Kernel: 6.1.0-22-2-amd64" 

iso.3.6.1.2.1.1.2.0 = OID: iso.3.6.1.4.1.8072.3.2.10 

iso.3.6.1.2.1.1.3.0 = Timeticks: (15974) 0:02:39.74 

iso.3.6.1.2.1.1.4.0 = STRING: "Azure Cloud Switch vteam <linuxnetdev@microsoft.com>" 

iso.3.6.1.2.1.1.5.0 = STRING: "sonic" 

iso.3.6.1.2.1.1.6.0 = STRING: "NotConfigured" 

iso.3.6.1.2.1.1.7.0 = INTEGER: 72 

iso.3.6.1.2.1.1.8.0 = Timeticks: (2) 0:00:00.02 

iso.3.6.1.2.1.1.9.1.2.1 = OID: iso.3.6.1.6.3.10.3.1.1 

iso.3.6.1.2.1.1.9.1.2.2 = OID: iso.3.6.1.6.3.11.3.1.1 

iso.3.6.1.2.1.1.9.1.2.3 = OID: iso.3.6.1.6.3.15.2.1.1 

iso.3.6.1.2.1.1.9.1.2.4 = OID: iso.3.6.1.6.3.1 

iso.3.6.1.2.1.1.9.1.2.5 = OID: iso.3.6.1.6.3.16.2.2.1 

............................................. 

 

    • Related Articles

    • How to Configure snmp in broadcom sonic

      SNMP Overview Simple Network Management Protocol (SNMP) is a widely used application-layer protocol that enables centralized monitoring and management of network devices such as switches, routers, and servers. It supports real-time alerts, ...
    • How to configure subinterface

      Sub-Interface: Sub interfaces divide the parent interface into two or more virtual interfaces on which you can assign unique Layer 3 parameters such as IP addresses and dynamic routing protocols. The IP address for each sub interface should be in a ...
    • How to configure BGP

      BGP (Border Gateway Protocol) Objective BGP (Border Gateway Protocol) is the protocol that enables the global routing system of the internet. It manages how packets get routed from network to network by exchanging routing and reachability information ...
    • How to Configure eBGP and iBGP with Peer-Groups

      BGP (Border Gateway Protocol) with peer-group configurations Objective This document explains how to configure eBGP (External BGP) and iBGP (Internal BGP) using peer-groups on routers. Peer-groups help simplify BGP configuration by grouping neighbors ...
    • Basic Show Commands in Broadcom sonic

      Basic Show Commands Objective This document explains how to use basic show commands on broadcom sonic to retrieve system information, hardware details, software versions, and transceiver status. These commands help network administrators quickly ...