Page 1 of 1

HowTo: RPi as WakeOnLAN server

PostPosted: Fri Apr 12, 2019 7:48 am
by peter_b
This is actually based on the steps described on
Raspberry Pi As Wake on LAN Server.

1) Install "etherwake" package:
Code: Select all
$ apt install etherwake

In my network, I've got all ethernet MAC IDs configured in my ISC DHCP configuration (Raspbian/Debian), so I'm using that "dhcpd.conf" config file as a lookup table when I want to WOL a machine by its hostname.

Here's the quick-n-dirty BASH hack:
Code: Select all


# Grep the MAC address from the DHCP config file:
CMD="grep -A 2 -i 'host $TARGET' $DHCP_CONF | grep 'hardware ethernet' | cut -d ' ' -f 5"
MAC_ID=$(eval "$CMD")
# MAC IDs are 17 digits long. Cut it:

echo "$TARGET=$MAC_ID"
etherwake $MAC_ID

You can call that like this:

It will then search the hostname in dhcpd.conf, grep its ethernet line and cut that to the address string.
When it has that, it calls `etherwake`. The target HOSTNAME should now wake up :D

Thanks Quintaar! :)