Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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

by lhoward (Vicar)
on Mar 30, 2001 at 22:32 UTC ( #68459=note: print w/replies, xml ) Need Help??

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

I can think of a few ways, but they're kind of out there and won't work most of the time:
  • If the remote box is running SNMP and you know its community string you can SNMP poll it to get its mac address
  • If the entire path from you to the remote host is IPv6 and not IPv4, the boxes MAC address is part of its IPv6 address by default (this can easily be overridden).
Why do you need the remote box's MAC address? If you're trying to use MAC address to uniquely identify users or something like that MAC (or any type of network address) is not the way to do it.
  • Comment on Re: How can I find a MAC address from aremote IP ?

Replies are listed 'Best First'.
Re: Re: How can I find a MAC address from aremote IP ?
by magoo (Initiate) on Mar 31, 2001 at 00:01 UTC
    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 :)

      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.


      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
Node Status?
node history
Node Type: note [id://68459]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2018-03-21 21:36 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (270 votes). Check out past polls.