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
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