Listen for wakeonlan request
Solution 1:
With nc
you can listen on an udp port. The magic packet usually is sent to port 9 via broadcast. So, the command would be:
nc -ul 9
Depending on the nc implementation, you may also need to provide the -p
flag:
nc -ul -p 9
To test it use the wakeonlan
command...
wakeonlan <your-mac>
...and see in the nc terminal the output.
Solution 2:
The other answer only works for "Wake-Up!"-packets coming in via UDP:9 (like from wakeonlan
, and not for packets of the dedicated ethertype 0x0842 (AMD magic packet format) (e.g. etherwake
).
To grab the relevant part of the payload for both of those wake-up methods:
tcpdump -UlnXi eth0 ether proto 0x0842 or udp port 9 2>/dev/null |
sed -nE 's/^.*20: (ffff|.... ....) (..)(..) (..)(..) (..)(..).*$/\2:\3:\4:\5:\6:\7/p'
Output is one mac-address per line, line-buffered.