An commandline daemon that wakes up a device on the local network when accessed
You could think of this program as an "automatic Wake-On-LAN" daemon.
Let's suppose you have a large server, media box or even your PC and you want to easily access those devices from a network while saving power.
Instead of manually sending WOL "magic packets" using a program or app, what if instead we could wake up the device when accessed. Example being, ssh-ing into a Mac Mini while in sleep mode.
Well, quite simply actually. It detects outgoing ARP requests (basically asking the router whether or not we can get to the device) and if they match the host and target it sends a WOL packet.
Yes, but not all of them. Certain Broadcom ethernet chips do not feature waking on ARP, which forced me to make this program by myself.
sudo ethtool -s yournetworkdevice0 wol a
You'll get a Operation not supported
otherwise if your card doesn't support it.
Most programmers are lazy bastards.
Use-case 1: Large server that drains Watts upon Watts of power and your landowner is yelling at you because of the high-power bills. But you have a small and power-efficient secondary device, such as a Raspberry Pi that could indeed run 24/7 without using much power. Using the Raspberry Pi, you could route all the big server traffic to the Raspberry Pi and using simple proxies reroute it back to the big server. Nginx supports this out of the box. This assumes you know how to automatically suspend your server, which I won't get into.
Use-case 2: You are too lazy to wake up your NAS at home using a 3rd party program, so instead you can run this as a daemon in the background on any UNIX-like OS. Don't worry, this program uses only a few kilobytes of RAM and barely any CPU time since it's all UNIX code without any dependencies.
make
./wake-on-arp -h
to see what arguments you have to fill in
There's a config file for that, it's (usually) located in /etc/wake-on-arp.conf
However, it's only there when you run make install
Once compiled,
make install
(as root)
If you like, you can use systemd to run and monitor this tool
sudo vi /lib/systemd/system/wakeonarp.service
[Unit]
Description=Wake on LAN based on ARP
After=network-online.target network.target rsyslog.service
Wants=network-online.target network.target rsyslog.service
[Service]
Type=simple
ExecStart=/usr/local/bin/wake-on-arp
Restart=on-failure
#in case network was not online
RestartSec=15
[Install]
WantedBy=multi-user.target
sudo systemctl enable wakeonarp.service
sudo systemctl start wakeonarp.service
If you use a subnet mask fitting the whole network, you may want to monitor which IP did wake up your target.
If the event was in the last few days or since the last reboot, you don't need any additional configuration and can just use
systemctl status wakeonarp.service
or journalctl -u wakeonarp.service
But if you need to archiv the wakeup reasons, you may want to store it outside of the journal files with the help of rsyslog.
sudo vi /etc/rsyslog.d/wake-on-arp.conf
if $programname == 'wake-on-arp' then /var/log/wake-on-arp.log
sudo systemctl restart rsyslog
It's included in this repository. However, since the repository features code from other projects, it also includes licenses from these repositories (for those specific parts):