SNMP get interface number

Solution 1:

SNMP tables are ordered by an index that can change between systems and reboots. For this reason you should always look up the index values of tables that can have multiple entries before looking up associated statistics and not rely solely on the OID remaining static.

That being said, snmptable will do this for you in a pinch!

snmptable -v2c -c <community string> <hostname> IF-MIB::ifTable

There are many more columns that you'd like so you could clean up the results with awk, like so:

snmptable -CH -v2c -c <community string> <hostname> IF-MIB::ifTable | awk 'BEGIN { OFS="," } { print $1, $2, $3, $5 } '