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 –csystem.sysContact.0 = Helpdesk 800-555-2992ORARO Router .1.3.6.1.2.1.1.4.0
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 –cORARW Router.1.3.6.1.2.1.1.4.0 ssystem.sysContact.0 = Ian Brown 555-1221 freebsd%"Ian Brown 555-1221"snmpget –v1 –cORARO RoutersysContact.0system.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 -cORARO RouterifDescrinterfaces.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 ...