HowTo: RPi as WakeOnLAN server

Step-by-Step descriptions of how to do things.

HowTo: RPi as WakeOnLAN server

Postby peter_b » Fri Apr 12, 2019 7:48 am

This is actually based on the steps described on instructables.com:
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
#!/bin/bash

TARGET="$1"
DHCP_CONF="/etc/dhcp/dhcpd.conf"

# 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:
MAC_ID=${MAC_ID:0:17}

echo "$TARGET=$MAC_ID"
etherwake $MAC_ID


You can call that like this:
"./wol.sh HOSTNAME"

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! :)
  • 0

User avatar
peter_b
Chatterbox
 
Posts: 315
Joined: Tue Nov 12, 2013 2:05 am
Reputation: 3

Return to HowTo's

Who is online

Users browsing this forum: No registered users and 0 guests

Who is online over last 24 hours

Users browsed this forum in the last 24 hours: No registered users and 3 guests

cron
Reputation System ©'