SNMP – How to Get Interface Number

snmp

Does someone know how to get a interface number for SNMP for nic cards? And how or with what, a SNMP walk?

I have some cards which have the same OID in SNMP but change the port randomly. I was wondering if there was a command I could send from Windows or Linux to get the interface numbers or list all interfaces with their ports like this:
Found standard interfaces:

1: (001) lo,Connected,10 MBit/s,Software Loopback,
2: (002) eth0,Connected,100 MBit/s,Ethernet,
3: (003) eth1,Not Connected,0 KBit/s,Ethernet,

Thanks

Best Answer

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 } '
Related Topic