Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
572 views
in Technique[技术] by (71.8m points)

ip address - SNMP OID to map MAC addresses to ip addresses?

I have written some C# code that I am using to run an file "snmpwalker.exe" that is returning details about so cisco switches when I pass in the correct community string ip address and vlan information with an OID. I have been able to get enough information to be able to map the MAC addresses to the switch's ports but I want to also find out the ip addresses. Does anyone know what the OID for snmp would be to get back a list with mac addresses and ip addresses on a cisco switch?

I haven't used snmp before or done much in networking so I am new to how most of this stuff works.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

A switch is a layer-2 device. It works with MAC addresses and knows nothing about IP addresses.

A DHCP server will only have MAC addresses for devices that have requested an IP address. Servers, switches, printers etc. probably won't use DHCP.

Other ideas:

  • If your subnet is small you could ping every address and look at the ARP cache in your host. This should find most things with an IP address, but not everything necessarily responds to a PING. For a large subnet this will be slow, and isn't really good practice.
  • You could ping the multicast all-hosts address (224.0.0.1) and examine the ARP cache, but that will only find multicast capable devices.
  • Ping the subnet broadcast address and examine the ARP cache. Again, not everything will necessarily respond.

Combining these approaches will probably get most things, but you'll have trouble finding, for example, a printer with a static address that doesn't respond to ping.

If you don't understand these terms find a tutorial on networking before you go any further.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...