Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Re: How can I find a MAC address from aremote IP ?

by magoo (Initiate)
on Mar 31, 2001 at 00:01 UTC ( [id://68485]=note: print w/replies, xml ) Need Help??

in reply to Re: How can I find a MAC address from aremote IP ?
in thread How can I find a MAC address from aremote IP ?

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 :)

  • Comment on Re: Re: How can I find a MAC address from aremote IP ?

Replies are listed 'Best First'.
Re: Re: Re: How can I find a MAC address from aremote IP ?
by riffraff (Pilgrim) on Mar 31, 2001 at 02:00 UTC
    On the other hand, there is a mac address to ip address mapping in snmp mib variables (as long as your switch supports it). Without looking it up, it might be something like PhysAddrToInetAddr. ....

    Nope, wait, after just looking it up, ip.ipNetToMediaTable.ipNetToMediaEntry.* is what you want.

    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.


      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.


Re: Re: Re: How can I find a MAC address from aremote IP ?
by lhoward (Vicar) on Mar 31, 2001 at 01:51 UTC
    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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://68485]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-06-25 05:56 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.