Post

Understanding snmp

Simple Network Management Protocol (SNMP) is a widely used protocol for network management that provides a standardized framework for monitoring and managing network devices.

Understanding snmp

SNMP

Simple Network Mangement Protocol (SNMP) is a standard protocol used for monitoring, managing, and configuring devices on a network.

It enables network administrators to collect data, monitor performance, and identify issues on devices like routers, switches, servers, printers etc.

About SNMP:

AttributeDescription
OSI LayerApplication Layer (Layer 7)
Transport ProtocolUDP
Ports161/UDP for agents communication, 162/USP for traps
VersionsSNMPv1, SNMPv2c, SNMPv3
Common DevicesRouter switches, Server, printers, IoT Devices

Key components:

SNMP Manager:

  • Central system that issues requests to gather data and control network devices.
  • It is a centralized system used to monitor the network. It is also known as Network Management Station (NMS).

Responsibilities:

  • Sends requests to SNMP agents (e.g., GET, SET, GETNEXT).
  • Receives responses or TRAPs from SNMP agents.
  • Maintains a centralized view of the network status.
  • Logs, alerts and performs automated tasks.

Examples:

  • SolarWinds
  • Manage Engine
  • Zabbix

SNMP Agent:

  • SNMP agent is a software process running on networked devices.
  • Software running on a managed devices that reponds to requests from SNMP manager.
  • Collects and stores device specific information.

Responsibilities:

  • Listens for SNMP requests on UDP port 161.
  • Responds with requested info (e.g., Device uptime, CPU usage).
  • Sends SNMP TRAPs or INFORMs to the manager to notify issues/events.
  • Pull data from internal device metrics and make it accessible.

Examples:

  • snmpd on Linux
  • Bulit-in agents in Cisco/Juniper devices.

MIB:

  • Management Information Base (MIB) is a virtual database (a hierarchical structure) that defines what information an SNMP agent can provide.
  • Defines the data objects that can be managed on a device.

Responsibilities:

  • Standardize all the device info (uptime, interfaces, errors, etc.)
  • Defined Object Identifiers (OIDs): Unique addresses to data points.
  • Both manager and agent refer to the MIB to understand each other.

Examples:

  • sysDescr.0: System description
  • OID: .1.3.6.1.2.1.1.1.0

Installation of SNMP agent on Linux:

Installation:

  1. First update your system.

    1
    
     sudo apt update
    
  2. Then install SNMP using apt:

    1
    
     sudo apt install snmp snmpd
    
  3. Check if it is installed or not:

    1
    
     sudo systemctl status snmpd
    

    image.png

Configuration:

Edit the config file:

1
sudo nano /etc/snmp/snmpd.conf

Common changes:

1
2
3
4
rocommunity public
agentAddress udp:161
sysLocation "Author's machine"
sysContact [email protected]

Reload the SNMP service:

1
sudo systemctl restart snmpd

Test SNMP:

1
snmpwalk -v2c -c public localhost

Output:

image.png

Displaying System Description:

1
snmpwalk -v2c -c public localhost 1.3.6.1.2.1.1.1.0

image.png

Common SNMP OIDs and Their Uses:

OIDNameMIBDescription / Use
.1.3.6.1.2.1.1.1.0sysDescr.0SNMPv2-MIBDescribes system: OS, version, hardware, etc.
.1.3.6.1.2.1.1.3.0sysUpTime.0SNMPv2-MIBTime since the device last rebooted
.1.3.6.1.2.1.1.5.0sysName.0SNMPv2-MIBHostname of the device
.1.3.6.1.2.1.1.4.0sysContact.0SNMPv2-MIBContact person for this device
.1.3.6.1.2.1.1.6.0sysLocation.0SNMPv2-MIBPhysical location of the device
.1.3.6.1.2.1.2.2.1.2.XifDescr.XIF-MIBDescription of interface X
.1.3.6.1.2.1.2.2.1.8.XifOperStatus.XIF-MIBInterface status: up/down/testing
.1.3.6.1.2.1.2.2.1.10.XifInOctets.XIF-MIBBytes received on interface X
.1.3.6.1.2.1.2.2.1.16.XifOutOctets.XIF-MIBBytes sent out on interface X
.1.3.6.1.2.1.25.1.1.0hrSystemUptimeHOST-RESOURCES-MIBSystem uptime in hundredths of a second
.1.3.6.1.2.1.25.2.3.1.6.XhrStorageUsed.XHOST-RESOURCES-MIBAmount of used storage in block units
.1.3.6.1.2.1.25.3.3.1.2.XhrProcessorLoad.XHOST-RESOURCES-MIBCPU load of processor X
.1.3.6.1.4.1.2021.4.5.0memTotalRealUCD-SNMP-MIBTotal physical RAM
.1.3.6.1.4.1.2021.4.6.0memAvailRealUCD-SNMP-MIBAvailable physical RAM
.1.3.6.1.4.1.2021.11.9.0ssCpuIdleUCD-SNMP-MIB% of CPU time spent idle
.1.3.6.1.4.1.2021.10.1.3.1laLoad.1UCD-SNMP-MIB1-minute load average
This post is licensed under CC BY 4.0 by the author.