Wake-on-LAN (WoL)
Configure the Wake-on-LAN (WoL) Clients
Install wakeonlan and ethtool on your device.
sudo apt install wakeonlan
sudo apt install ethtoolIdentify the ethernet interface of your device.
ip aIt will be the one that has the 192.168.xx.xx IP address assigned. For example:

Check your existing Wake-on-LAN status. Replace enp2s0with the actual ethernet interface of your device.
If you see the following, you can proceed to the next sub-section. Else, continue following along.
If you see Wake-on: d or any other letter here, it means wake-on-lan is disabled or not optimally configured so you need to change this letter to g.
Next, make this configuration persistent even after rebooting your system.
Add the following lines to your file.
Example of how your file should look like.
CTRL+O, ENTER, CTRL+X to save and exit.
Apply the new configuration.
Enable Wake-on-LAN in BIOS
Restart your device and press F2 repeatedly during boot to enter BIOS Setup.
Select
Advanced, then select thePower menu.Expand the
Secondary Power Settingssub-menu and set Wake-on-LAN from S4/S5 to: Power On - Normal Boot.Press F10 to save and exit the BIOS Setup.
Set up Wake-on-LAN server
OPTIONAL: Connect your Raspberry Pi to your WiFi network
Install the network manager package.
Connect to your WiFi network.
Follow the terminal UI to Activate a connection>>Choose WiFi SSID>>Enter password. Just like how you would normally connect to a WiFi network!
Once you are connected to your WiFi network, press ESC to exit the nmtui terminal UI.
Configure the Wake-on-LAN server
Create a wake-on-LAN script on your Raspberry Pi that covers all your other devices.
Paste the following content:
CTRL+O, ENTER, CTRL+X to save and exit.
Make this script executable.
We want this script to run automatically whenever our WOL server restarts after a power failure. Create a new systemd service file to run the script at startup.
Add the following content:
Load and run the WOL service.
Use CTRL+C to exit the monitoring/logging view.
Manual Wake-on-LAN via Telegram Bot (Optional)
This is useful as a backup to the automated WOL setup above in case you need to manually "wake up" your devices remote after recovery from a power failure.
Create a new Telegram bot by following the steps below.
Open Telegram and Message the BotFather:
Search for "BotFather" in Telegram and start a conversation.
Create a New Bot:
Send
/newbotto the BotFather.Follow the instructions in the BotFather chat to name your bot and get its API token.
Save the API Token:
Example token:
123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ.
Add the Bot to Your Private Group:
Invite the bot to your Telegram group.
Get Your Chat ID:
Use the bot to retrieve the chat ID:
Send a message in the Telegram group with your bot
Navigate to
https://api.telegram.org/bot<YourBOTToken>/getUpdateson your browser while replacing<YourBOTToken>with your actual Telegram bot API token
Install dependencies on your WoL server (Raspberry Pi).
Create a new folder to store the bot files.
Create the .env file to store private and sensitive information such as your Telegram bot token and chat ID.
Add your Bot API Token and Chat ID as variables into .env
CTRL+O, ENTER, CTRL+X to save and exit.
Secure the .env file so that only your current user can access the file.
Create the Telegram bot script.
Paste the following content:
CTRL+O, ENTER, CTRL+X to save and exit.
Make this python file executable.
Create a systemd service file for the bot:
Add the following content:
CTRL+O, ENTER, CTRL+X to save and exit.
Load and run the WOL bot service.
Use CTRL+C to exit the monitoring/logging view.
Use a DNS that allows connection to Telegram
This tells the network manager of your Raspberry Pi (systemd-resolved) to ALWAYS use these DNS servers.
Last updated