Extracting Router Information via SNMP Tools

Problem

You wish to extract or change router information via SNMP.

Solution

To extract router information via SNMP, we will use the suite of SNMP tools provided with the NET-SNMP toolkit (see Appendix A for more details).

Use snmpget to extract a single MIB object from the router’s MIB tree. This example uses snmpget to extract the router’s system contact information:

freebsd% snmpget –v1 –c ORARO Router .1.3.6.1.2.1.1.4.0
system.sysContact.0 = Helpdesk  800-555-2992

Use snmpset to alter MIB objects within the router’s MIB tree. The next example demonstrates how to modify MIB variables, using snmpset to change the system contact information:

freebsd% snmpset –v1 –c ORARW Router .1.3.6.1.2.1.1.4.0 s "Ian Brown 555-1221"
system.sysContact.0 = Ian Brown 555-1221
freebsd% snmpget –v1 –c ORARO Router sysContact.0
system.sysContact.0 = Ian Brown 555-1221

The snmpwalk utility extracts a series of MIB objects from the router’s MIB tree. This example uses snmpwalk to extract all of the router’s interface descriptions:

freebsd% snmpwalk –v1 -c ORARO Router ifDescr 
interfaces.ifTable.ifEntry.ifDescr.1 = "Ethernet0"
interfaces.ifTable.ifEntry.ifDescr.2 = "Serial0"
interfaces.ifTable.ifEntry.ifDescr.3 = "Serial1"
interfaces.ifTable.ifEntry.ifDescr.4 = "Null0"
interfaces.ifTable.ifEntry.ifDescr.5 = "Loopback0"
interfaces.ifTable.ifEntry.ifDescr.6 = "Serial0.1"
freebsd%

Discussion

For this recipe, we chose to demonstrate basic SNMP functionality by using the suite ...

Get Cisco IOS Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.