How to convert a MAC address to the corresponding IP address?

前端 未结 4 709
春和景丽
春和景丽 2021-01-14 22:08

I am looking for an easy way to convert a MAC address to the corresponding IP address in a local network. In my case, there are only two devices: a very normal PC (192.168.0

4条回答
  •  鱼传尺愫
    2021-01-14 22:49

    We had to do this a while back, but I don't think we got it working properly.

    I don't have the API calls off-hand, but they're easy to find in the Windows API. That's what we used, so our solution wouldn't be portable to non-Windows systems.

    In our case, we ran into the same hurdle--no easy translation. What we ended up having to do was get a list of all the NICs available, and then loop through each one trying to match our given MAC address against the MAC address obtained from the NIC structure.

    Once we found a match, we looked up the IP address given to the NIC structure.

    We kept on going to see if we found any other matches in order to log an error. It's a good thing we did, because I believe we did find it multiple times, and it wasn't due to a MAC address being cloned.

    That's when we learned that this would be an even harder problem, and we decided to abandon the whole thing and stick to just IP addresses.

提交回复
热议问题