Server Wake-on-LAN on access

Most ethernet NICs support Wake on LAN feature – when a so-called magic packet wakes up the computer. This can save money, as running a Mac Pro 1,1 server fully awake could cost you at least $24.5 per month of electricity in California prices (that’s at the lowest tier of consumption).

To put my server to sleep, I use powernap (easy install via apt in Ubuntu). As I use ssh to access files, tracking TCP port 22 connection to keep server awake is a no brainer config setting.

There is a number of software utilities that could be used to send a magic packet to wake a remote machine, but if all you want is to access a file, firing up the utility each time seems too much hassle.

Running the command below on a unix-based router (OpenWRT, DD-WRT) connected to the same LAN as server will send a magic packet to your server on any access attempt. It works by sniffing for broadcast ARP packets looking for server’s IP address (e.g. 192.168.1.191) and issues a magic packet to its MAC address (e.g 00:17:f2:0a:a6:3f).

Just edit the address values below, substituting LAN bridge interface, server’s IP address and MAC address, and put this line into the startup script of your router:

tcpdump -i eth1 -l arp and ether[0x26:1]=192 and ether[0x27:1]=168 and ether[0x28:1]=1 and ether[0x29:1]=191|while read -r line; do etherwake -i eth1 00:17:f2:0a:a6:3f; done&

good  luck!

Leave a Reply

Your email address will not be published.