cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
12990
Views
15
Helpful
4
Replies
Highlighted
Beginner

SNMP: How to get list of IP addresses and corresponding interface names

Hello,

i have list of IP addresses of interfaces of router. I need to get the corresponding interface names (e.g. fa0/0) so that i can match them with the list of ip addresses (e.g. i have ip 192.168.1.1 and i need to find out that it is IP of fa0/0). Is there any MIB in SNMP which can be utilized for that purpose?

Thank you very much.

jakub

4 REPLIES 4
Highlighted
Cisco Employee

Hi Jakub,

* you can use  IP-MIB object ipAdEntIfIndex (1.3.6.1.2.1.4.20.1.2) to identify IP Address. for a specific interface and its ifIndex.  Again, these interface ifIndices can be translated through ifDescr (1.3.6.1.2.1.2.2.1.2) to map the specific interface description.

ipAdEntIfIndex (1.3.6.1.2.1.4.20.1.2)

Description    "The index value which uniquely identifies the interface to which this entry is applicable. The interface identified by a particular value of this index is the same interface as identified by the same value of the IF-MIB's ifIndex."

For example :

snmpwalk -v2c -c private 10.104.149.18 1.3.6.1.2.1.4.20.1.2    <<=== ipAdEntIfIndex

   IP-MIB::ipAdEntIfIndex.1.1.1.231 = INTEGER: 108

   IP-MIB::ipAdEntIfIndex.2.2.2.1 = INTEGER: 157

   IP-MIB::ipAdEntIfIndex.7.7.7.100 = INTEGER: 107

IP-MIB::ipAdEntIfIndex.10.104.149.18 = INTEGER: 78      ====>> 78 is Management

Interface (Vlan1) ifIndex

   IP-MIB::ipAdEntIfIndex.11.11.1.1 = INTEGER: 91

   IP-MIB::ipAdEntIfIndex.11.11.2.2 = INTEGER: 92

   IP-MIB::ipAdEntIfIndex.11.11.3.3 = INTEGER: 93

   IP-MIB::ipAdEntIfIndex.51.51.51.2 = INTEGER: 100

   IP-MIB::ipAdEntIfIndex.55.55.55.2 = INTEGER: 101

   IP-MIB::ipAdEntIfIndex.61.61.61.1 = INTEGER: 102

   IP-MIB::ipAdEntIfIndex.65.65.65.5 = INTEGER: 103

   IP-MIB::ipAdEntIfIndex.79.161.80.43 = INTEGER: 109

   IP-MIB::ipAdEntIfIndex.99.1.1.1 = INTEGER: 5

   IP-MIB::ipAdEntIfIndex.100.1.1.1 = INTEGER: 160

   IP-MIB::ipAdEntIfIndex.127.0.0.51 = INTEGER: 79

   IP-MIB::ipAdEntIfIndex.192.168.10.1 = INTEGER: 105

   $

* The above result shows the IP addresses associated with different ifindex(es).To check which ifindex is associated with each interface, you can use the ifDescr (1.3.6.1.2.1.2.2.1.2) OID.

   $ snmpwalk -v2c -c private 10.104.149.18 ifDescr

   IF-MIB::ifDescr.1 = STRING: GigabitEthernet1/1

   IF-MIB::ifDescr.2 = STRING: GigabitEthernet1/2

   ��..

   ��..

   IF-MIB::ifDescr.77 = STRING: GigabitEthernet9/8

   IF-MIB::ifDescr.78 = STRING: Vlan1      <<===  Management Interface (Vlan1) IfIndex is 78

   IF-MIB::ifDescr.79 = STRING: EOBC0/0

   IF-MIB::ifDescr.80 = STRING: Null0

Thanks-
Afroz
[Do rate the useful post]
****Ratings Encourages Contributors ****

Thanks- Afroz [Do rate the useful post] ****Ratings Encourages Contributors ****
Highlighted

Its is very helpful! Thanks...

Highlighted

Glad , it helped you 

Thanks-
Afroz
[Do rate the useful post]
****Ratings Encourages Contributors ****

Thanks- Afroz [Do rate the useful post] ****Ratings Encourages Contributors ****
Highlighted
Beginner

This is very helpful! Thank you @AFROJ AHMAD for the great description.

Have anyone tried to append the IP to the Interfaces Table (IF-MIB::ifTable) as a Telegraf configuration?
I am trying to assign IP addresses to the ifIndex tags using Telegraf SNMP Plugin as a data collector. The configuration looks like this one here https://sbcode.net/grafana/cisco-switch-influxdb/.
Now all I want is, to be able to find out which IP Address is assigned to the interface an interface with the ifIndex<X>?

Is this possible? 

Kind regards and thanks in advance for your support! 
Mado

Content for Community-Ad