Can I determine the current IP from a known MAC Address?

后端 未结 7 416
难免孤独
难免孤独 2021-02-01 03:06

I have a shell script which uses etherwake to wake up a machine on my local network. After the machine is awake, I\'m not sure of the IP address.

While trying to answer

7条回答
  •  既然无缘
    2021-02-01 03:32

    The other methods presented here were unreliable, e.g. the output of ip neighbor did not always contain the most recent state, so I ended up re-scanning the network using arp-scan, and hence I simply used the output of the scanning to obtain the IP address for a given MAC address.

    For scanning a single network interface, simply use this:

    arp-scan -q -l --interface en4 2>/dev/null | grep "00:1E:C9:56:3C:8E" | cut -d$'\t' -f1
    

    The following command scans multiple network interfaces at once:

    { arp-scan -q -l --interface en0 2>/dev/null & arp-scan -q -l --interface en4 2>/dev/null } | grep "00:1E:C9:56:3C:8E" | cut -d$'\t' -f1
    

提交回复
热议问题