Get the MAC address of a remote PC?

I need to get the MAC address from a PC. The code I wrote so far is here (this is just a small part of the code).

public byte[] getMac(L2PcInstance player) { try { NetworkInterface ni = NetworkInterface.getByInetAddress(player.getClient().getConnectionAddress()); if (ni != null) { byte[] mac = ni.getHardwareAddress(); if (mac != null) { return mac; } } } catch (SocketException e) { _log.log(Level.SEVERE, "No MAC address.", e); } return null; } 

This code finds the MAC address of the PC on which I run it, but I need to get the remote MAC address.

+4
source share
1 answer

You cannot do this in Java, and if you do some research, you will find that the MAC address is actually not very useful for anything other than the Ethernet layer and the network adapters connected to it.

+6
source

Source: https://habr.com/ru/post/1380125/


All Articles