Listen for wakeonlan request

8

1

I would like to know how to listen for wakeonlan paquets on a running system. I know that my question if a little bit useless, because if a system is running, there is no need to wake up it!

Gael

Posted 2015-01-28T13:39:51.093

Reputation: 751

Answers

8

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.

chaos

Posted 2015-01-28T13:39:51.093

Reputation: 3 704

Using this I can see my magic packet is received, but if I turn off my computer with "shutdown now", I cannot wake it with wake-on-lan (this happened when I changed operators, while before it worked perfectly) – Reda Drissi – 2019-10-04T10:35:18.840

1

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 (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 per line, line-buffered.

Alex Stragies

Posted 2015-01-28T13:39:51.093

Reputation: 1 320