Generating a Report of Routing Table Information :
You need to extract the IP routing table from one of your routers.
The script in Example 2-2, rt.pl, uses SNMP to extract the routing table from a specified router, and displays this information to standard output (STDOUT).
The script expects to find a hostname or IP address of a router on the command line.
Example 2-2. rt.pl
The rt.pl script is written in Perl and uses NET-SNMP to extract the routing table information via SNMP. It expects to find both Perl and NET-SNMP in the /usr/local/bin directory. For more information on Perl or NET-SNMP, please see Appendix A.
Before using the script, you must define the variable $snmpro to contain the SNMP read-only community string for the router:
The output from the script is relatively straightforward, except for static routes and directly connected routes, which require a little explanation.
For static routes, the output shows a value of local in the protocol field, and an interface name of Local. Directly connected routes also appear as local protocol information, but the interface name is the real interface associated with this route.
For example, the route 172.20.0.0 255.255.0.0 is a static route:
172.20.0.0 255.255.0.0 172.25.1.5 local Local
And 172.25.1.0 255.255.255.0 is a directly connected route:
172.25.1.0 255.255.255.0 172.25.1.7 local Ethernet0
Since this script queries only open standard SNMP MIB values, you can use it to extract IP route information from most any SNMP-enabled device, including nonCisco equipment.