Easiest way to get MAC address from a (non-local) IP address in IPv4

后端 未结 3 1993
一生所求
一生所求 2021-01-25 12:15

Is there an easy way to get a MAC address of a machine connected to my app via a TCP/IPv4 socket?

Or in more general terms:

If I have the IP address, what

3条回答
  •  渐次进展
    2021-01-25 12:17

    You can't, without having something (or the client itself) on that other network.

    MAC addresses are used on the second layer, the data-link layer, of the OSI model for networking. MACs are specific to Ethernet. When you get to the Internet, IP addresses are used. Not everything connected to the Internet uses Ethernet at lower layers.

    There are also other protocols other than IP that can be used.

    Basically, your computer only knows what is on its physical network segment. If it has to go outside for anything else, it only knows the MAC of the gateway to get there.

提交回复
热议问题