This is the command I passed
cmd = { "/bin/sh", "-c", "ping " + ip + " -c 2 && arp -a" };
The mac address obtained, but the mac address is not the client address I want, but the address on my cluster server. Is there any good way to obtain the client mac address through IP?
In fact, if you want to get the client's mac address, there is no way, because when the datagram passes through the router, the mac address in the message will be rewritten by the router, because the mac address of the sender in the link layer needs to be recorded , the general process is as follows:
You can also refer to this article:
Network-The MAC address and IP address of the data packet change or remain unchanged during the routing and forwarding process