How to get the MAC address for a remote system when I only know its IP address?

I am working on a Wake on LAN service that will work from a website and must interact with many different platforms - so there are no Windows solutions. When a user registers his system with a website, I need to get the MAC address to create a "magic" packet . I have a Java applet capable of doing this for me, and I know of an ActiveX control that will work, but I am wondering if there is a way to do this on the server side by requesting routers / switches. Since the system can reside on any of several physical subnets, using ARP will not work unless there is a way to configure the router to perform ARP on my behalf.

Does anyone know of any network APIs, proprietary or otherwise, that can be used to search for MAC addresses based on IP address? I think we use Cisco routers, but this is a complex network, and several providers may be present at different levels. I would like some background information on possible solutions before I send a sacrifice to the network gods. There is no point in humiliating yourself if it is technically impossible. :-)

EDIT: We have a network infrastructure configured to allow broadcasting, although figuring out the exact broadcast address, since network masks are not always / 24, is another puzzle that I need to solve.

+4
source share
11 answers

Currently, the application uses the Java 6 applet, which allows me to retrieve both the host name and MAC address from the remote system. I don't like having this dependency on Java 6, but Snow Leopard and Windows support it, so I can probably live with it.

On a related front, our netizens turned to me for some help converting some existing code into ASP.NET. During the conversation, I asked if they had live information about the MAC address (since they close the ports based on suspicious network activity - viruses / worms). It turns out they do, and we can use this project to access information from a network database.

+1
source

If you are on a local network using DHCP, you can look in the server database to get the MAC of the last user with this address. In the future, you can watch the network for ARP requests and cache responses in some table. You can also look at RMON or SNMP to try to query address tables on switches and routers.

It should be noted that in order to use WoL through routers, you need to either enable Directed Broadcasts, or you need a relay server in the local segment.

It has been a while since I played routers and swtiches, but this can serve as a starting point for requests using SNMP http://www.cisco.com/en/US/tech/tk648/tk362/technologies_tech_note09186a00801c9199.shtml

+4
source

Use the following:

getmac /s destIp 

To get the MAC address of the remote session.

+2
source

You said all I can think of ...

The source MAC address changes as a packet flight from device to device, so if the client is not on the same subnet, the server will not be able to obtain the MAC address. (You would do it through ARP)

A signed java applet or activex control will be the easiest solution. He will be able (almost passively) to get all the necessary information about the network (IE does not even request the launch of a signed applet)

If you are fully aware of the network using this service, you can probably request a list of gateway clients through SNMP or CDP. You could map IP addresses to MAC addresses ... but this is really vendor specific (but generic) and won't be much better (imo) than having an applet.

+1
source

I donโ€™t think there is a way to do this. When the IP packet passes through the first router, the host MAC information is lost (since you know that the MAC is used only in the ethernet layer). If the router closest to your computer could tell you the remote MAC code, it will only see the MAC of the next router between your PC and the "other end".

0
source

Start donating.

There is no general way to do this from a network point of view unless you have routers. When the router is on, you will never see the MAC address of the source system.

This assumes that the source system has only one network interface, therefore it has only one MAC address.

In fact, are you even sure that your โ€œmagic packageโ€ (no matter what it is) will reach the system you want to reach through routers? This is similar to the function that routers or other network infrastructure must perform.

0
source

The MAC address is used only in network segments and is lost at each hop. Only the IP is saved for end-to-end - and even then the IP address is rewritten when Natted. I assume that my answer is impossible if everything is not in the same network segment, or if your routers are configured for proxy arp (which is actually not realistic).

0
source

You can only get MAC entries in the ARP table for machines on the same network. If you connect to the machine through a router, you will only see the MAC address of the router in the ARP table. Thus, there is no way to find out the MAC address of external hosts if it is not a host on the same network (routers are not involved).

And by the way, there are many similar questions already on SO.

0
source

if it is a Windows system, you can use NBTSTAT -A this will return netbios information and the IP address is there

any management system, such as SMS or Altiris, will have this information

DHCP server is a good idea

If it is local, you can ping and then quickly run ARP -a, find the IP and the MAC will be there. You may need to write a small batch file.

if you have access to a PC, you can use WMI to access information for Nic with DHCP.

0
source

As stated above, we can get the mac address from a known IP address if this host is on the same subnet. The first ping is ip; then look at arp -a | grep and parse the string on nix * to get the mac address.

We can issue a system command from all standard programming languages โ€‹โ€‹and can analyze the output to get the address mac.Java api can execute the IP address, but I'm not sure that we are analyzing the ping output (some library can do this). It would be better to avoid issuing a system command and find an alternative solution, since this is not a platform. An independent way to do this.

Courtesy: Professor Saleem Bhatti

0
source

All Articles