cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
68536
Views
3
Helpful
8
Replies

Get IP Addres Interface via SNMP

cassio.gomes
Level 1
Level 1

Hi All...

how can I get Ip addres from interfaces router per interface ordem?

I´m using the OID .1.3.6.1.2.1.4.20.1.1, but, when I run snmpwalk, I receive this information:

IP-MIB::ipAdEntIfIndex.1.1.1.6 = INTEGER: 6

IP-MIB::ipAdEntIfIndex.1.1.1.7 = INTEGER: 7

IP-MIB::ipAdEntIfIndex.1.1.1.1 = INTEGER: 1

IP-MIB::ipAdEntIfIndex.1.1.1.2 = INTEGER: 2

IP-MIB::ipAdEntIfIndex.1.1.1.3 = INTEGER: 3

IP-MIB::ipAdEntIfIndex.1.1.1.4 = INTEGER: 4

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

this example, the Cisco Router has 7 interfaces.

Are there others OIDs that can I try ?

Thanks

Cassio Gomes

1 Accepted Solution

Accepted Solutions

Cassio,

You show you did the walk on IpAdEntAddr (1.3.6.1.2.1.4.20.1.1), but for whatever reason the returned results show ipAdEntIfIndex (1.3.6.1.2.1.4.20.1.2).

Either OID will provide you your IP address, in this case you do have 7 interfaces with IP addresses of 1.1.1.1 through 1.1.1.7.

You can cross-reference the INTEGER Number at the end of ipAdEntIfIndex with the interface index number provided with the object ifDescr.# (1.3.6.1.2.1.2.2.1.1) where # is the instance number.

HTH

Steve

View solution in original post

8 Replies 8

d-mark
Level 1
Level 1

Hi,

don't know what exactly you want. But if you want

something like "1.1.1.6 = Ethernt0", then you can also snmpwalk "mib-2.interfaces.ifTable.ifDescr" and put the 2 outputs together. The index value you get back from "ipAdEntIfIndex" correspond to the index value of "ifDescr"

HTH

Mark

dcheng.dns
Level 1
Level 1

If you just want the IP address, you can try doing an snmpwalk on ipAdEntAddr (.1.3.6.1.2.1.4.20.1.1). Odd, that's the same one you tried, but your name is different than what I see...

dc

Cassio,

You show you did the walk on IpAdEntAddr (1.3.6.1.2.1.4.20.1.1), but for whatever reason the returned results show ipAdEntIfIndex (1.3.6.1.2.1.4.20.1.2).

Either OID will provide you your IP address, in this case you do have 7 interfaces with IP addresses of 1.1.1.1 through 1.1.1.7.

You can cross-reference the INTEGER Number at the end of ipAdEntIfIndex with the interface index number provided with the object ifDescr.# (1.3.6.1.2.1.2.2.1.1) where # is the instance number.

HTH

Steve

Thanks all...

My problem is with ORDEM, when I run snmpwalk, I receive the IP :

IP-MIB::ipAdEntIfIndex.1.1.1.6 = INTEGER: 6

IP-MIB::ipAdEntIfIndex.1.1.1.7 = INTEGER: 7

IP-MIB::ipAdEntIfIndex.1.1.1.1 = INTEGER: 1

IP-MIB::ipAdEntIfIndex.1.1.1.2 = INTEGER: 2

IP-MIB::ipAdEntIfIndex.1.1.1.3 = INTEGER: 3

IP-MIB::ipAdEntIfIndex.1.1.1.4 = INTEGER: 4

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

I need receive in ordem 1,2,3,4,5,6,7 to put information in my database.

To solve this problem I did a script in PHP and it works perfect.

I don´t know why, but with this OID, the interfaces are showed out of sequence.

Thanks....

The SNMP agent is supposed to return the information in increasing lexographical order.

If the device is indeed responding out of sequence, then this is a bug.

Nadim,

My routers exihibit the same results as Cassio.

Here's a sample of me polling ifDesc

IF-MIB::ifDescr.25 = STRING: FastEthernet0

IF-MIB::ifDescr.26 = STRING: Serial0

IF-MIB::ifDescr.27 = STRING: Serial1

IF-MIB::ifDescr.28 = STRING: Serial2

IF-MIB::ifDescr.29 = STRING: Serial3

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

IF-MIB::ifDescr.31 = STRING: Loopback0

Then follow that up with a ipAdEntAddr

IP-MIB::ipAdEntAddr.10.10.10.100 = IpAddress: 10.10.10.100

IP-MIB::ipAdEntAddr.192.168.1.1 = IpAddress: 192.168.1.1

IP-MIB::ipAdEntAddr.192.168.253.253 = IpAddress: 192.168.253.253

IP-MIB::ipAdEntAddr.192.168.254.253 = IpAddress: 192.168.254.253

Finally I poll the ipAdEntIfIndex

IP-MIB::ipAdEntIfIndex.10.10.10.100 = INTEGER: 31

IP-MIB::ipAdEntIfIndex.192.168.1.1 = INTEGER: 26

IP-MIB::ipAdEntIfIndex.192.168.253.253 = INTEGER: 25

IP-MIB::ipAdEntIfIndex.192.168.254.253 = INTEGER: 25

It looks like the ifDesc is in lexigraphical order, but the ip address polls are in numerical order.

Steve

Hello Steve,

In your case the index is always increasing:

IP-MIB::ipAdEntIfIndex.10.10.10.100

IP-MIB::ipAdEntIfIndex.192.168.1.1

IP-MIB::ipAdEntIfIndex.192.168.253.253

IP-MIB::ipAdEntIfIndex.192.168.254.253

In Cassio's case:

IP-MIB::ipAdEntIfIndex.1.1.1.6

IP-MIB::ipAdEntIfIndex.1.1.1.7

IP-MIB::ipAdEntIfIndex.1.1.1.1 <-- Should be higher than 1.1.1.7

Yep--now that you point that out--it makes sense.

Thanks!

Steve

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: