Sometimes I need to locate quickly a computer in the buidling and
the only information I have at first, is the IP address (and
most of the time, it's a DHCP IP address, so there is many
places possible it could be).
With the MAC address, it's easy to locate on which port of
a switch it is plugged. And when i know on which port of
the switch it is plugged, I know where in the building the
computer is. There's many switchs and routers, so I wanted to have a little
perl script which would quickly gather all the informations
on a machine.
I think my problem is more how to use SNMP to get what
I want than a Perl one. Net::SNMP seems the way to do it. I just
need to find how, but that's not a perl issue now :) | [reply] |
snmpwalk <switchname> <communityname> IpNetToMediaEntry
Will list all (I believe) ports, which ip address is on that port,
and which mac address is associated with that ip address.
That could help, I guess.
riffraff
| [reply] [d/l] |
One thing I wanted to add, different companies support different mib
variables, even though there is a standard. Bay Networks (Nortel
Networks now) puts most of their stuff in the private enterprise
variables, so the above information may need to be modified.
riffraff
| [reply] |
Sounds to me like you have 2 possible angles to attack this problem:
- use SNMP to query the switches to see which IP is on which port.
Its been a long time since I've written an SNMP poll for a switch, but if I remmember
right I think the info you want is in the Bridge MIB.
- The static IP's should be pretty easy to locate. For the
dynamics you could query the DHCP server(s) to see what MAC a particular
IP is assigned to. This may or may not be doable (and may or
may ont be doable via SNMP), it depends on the capability of your DHCP server.
| [reply] |