Caveat emptor: this implementation of WoL is known to work on some machines and to be buggy on some others.
To build the module:
$ make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
To try it (last line enables WoL on magic packets, replace eth0
with the name of your Ethernet interface):
# rmmod alx
# insmod ./alx.ko
# ethtool -s eth0 wol g
The commands above will not survive to a reboot. If this module does not kill your dog and you want to install it permanently then DKMS is your friend.
The code comes from the alx module of the Linux kernel, and the old WoL implementation (removed from the kernel in 2013) which is adapted here for v4.12. The authors of the specific parts are listed in the file headers and in the history of the Linux repository.
The code is licensed under GPL 2.0.