Introduction: Raspberry Pi As Wake on LAN Server
First of all, this is an updated revision of my previous tutorial. The Raspbian image has changed, and the old version is no longer valid.
What does it do?
You can wake up any PC linked to the Raspberry Pi remotely. It can be done on the local network as well as from the internet. This means you no longer have to keep your PC on, to access the files remotely. You can wake up the PC within seconds when needed, saving a lot of power in the process.
Running a LAN cable may not always be a feasible solution. If your PC is connected to the internet via WIFI, and the card does not support Wake on LAN, you have no other options of waking up the PC remotely. RPI as WOL server solves this.
The RPI is constantly awake and is able to receive a request to wake the PC through the LAN interface. When the Magic Packet is received by the PC via LAN cable, it wakes up. Simple as that.
What do I need?
You will need the following:
- a Raspberry Pi with the ethernet port and WIFI connectivity
- a Raspbian Jessie image
- an ethernet cable
- a PC which has a LAN port with Wake On Lan support (most of them)
- an ethernet cable
- 10 min of your time
Step 1: The Setup
The physical set up
I don't think this could be any easier. LAN cable has 2 ends plug one of them to the PC LAN port with WOL support, the other to the Raspberry Pi! Power everything on.
The software setup
If you never connected a Raspberry Pi to the PC - here is a 4 step guide for you (no keyboard, or screen required)
I would recommend you to assign static IP to both interfaces (wlan and eth0) here is a handy guide. It builds on the 4 step guide above.
If you are already connected to the Raspberry PI and have wlan and eth IP static, go to the next step. I do recommend you to check the Guide 2 from this step before going further.
Step 2: Wake on LAN - ENABLED
Depending on the network card that your PC has there are few ways to check that the option is enabled.
When computer boots up, hitting Del will boot it into BIOS mode, this is where some of the network cards have additional settings. Check in BIOS for Wake on LAN settings if you are unable to turn it on from Windows.
Open Network settings and go to Network Adapters list. Select your LAN adapter and click on properties. In the Power management tab you will find options to allow Windows to wake/put to sleep the device and to enable Magic Packet. Make sure all of this is enabled.
Additional network card settings can be found in the advanced tab. You may see options in regards to the Wake on LAN and Magic Packet. Make sure these are enabled.
Step 3: Raspberry PI Side of Things
If you configured the RPI in the same way as in the Guide 2 (see step 2) your microcomputer will have a link via LAN with the computer but will use the WIFI to connect to the internet.
This is important because we have to force the Magic Packet to go through the eth0 instead of WIFI. The best way to do this is to use the etherwake:
sudo apt-get install etherwake
Once this is installed, you have to go to the PC and note the MAC address of the LAN adapter the RPI is connected to. (click on the details of that connection to reveal the IP and MAC listed as AA:BB:CC:DD:EE:FF in the example ).
the command to wake your PC up is:
sudo etherwake -i eth0 AA:BB:CC:DD:EE:FF
This method requires sudo, but allows you to specify the interface, which is what we need. You will have to issue this command via SSH (or type in terminal) each time you want to wake up the PC.
You could save it also as a bash file (save it as wol.sh):
#!/bin/bash<br>sudo etherwake-i eth0 AA:BB:CC:DD:EE:FF
And open the file with
sudo bash /path/to/file/wol.sh
Step 4: Booting Up From the Internet
You can skip to the next step if you don't need to wake up your PC from outside of your local network. Otherwise, we will need few more things to take care of.
I stressed the static IP for WIFI and LAN for a reason in step 2. This means we can now expose the SSH port on the router and forward it to the RaspberryPI. Sounds complicated? Not really.
You will need access to your router, nowadays most of them have the port forwarding option. Log in to your router *(see router instructions) and find the settings for port forwarding.
You want to forward port 22 (default for SSH, if you changed the port for SSH act accordingly) and forward it to the WIFI IP (you can check the assigned IP by typing ifconfig in terminal). It's advisable to reserve the IP in DHCP settings to make sure no other device will take it when your RPI is offline, you can find this option in most of the routers.
If your external IP changes often, you will need a DNS to streamline the process. DNS lets you assign a fixed name to the IP address. If your IP address changes, DNS will update the IP (automatically or manually) and you will be able to connect.
I used www.noip.com it's free but requires you to log in every 30 days to continue use of the DNS. Pick your username
and google ''my ip'' to get the current IP if the system is unable to detect it for some reason.
Step 5: The Magic 'one Button' Wake Up (optional)
The examples from the video give you an idea how you could streamline the wake-up process.
The hard way
The impressive way
Hey you Android user - (sorry Apple lovers, do your own research) ever heard about Tasker ? In short it's an app that lets you do the hard way automatically. Voice controls, mobile buttons, shake to wake you name it.
A plugin named AutoTools will let you send the SSH command to the raspberry. I have a bunch of tutorials on how to use Tasker for awesome things. Here is the beginner's guide. Watch the video 1 and 2 to feel comfortable with the interface.
Create a Task in Tasker, add an action - plugin AutoTools SSH. In the config screen add the details. If you going to use the WOL on local network use the local IP, otherwise use the DNS. The video with a tutorial shows you this part in detail, I will add the task description here:
Wake up PC (24) A1: AutoTools SSH <br>[ Configuration:Server: yourdns.ddns.net<br>Port: 33<br>Username: pi<br>Password: *******<br>Command: sudo etherwake -i eth0 00:00:00:00:00<br>Command Variable: atsshresult <br>Timeout (Seconds):60 ]
You dont have to worry about the IF condition unless you feel comfortable with the Tasker. Don't add it. (it wont add by default)
Once the task is created (create one for the local network and one for the internet) assign the icons to each task, and then pick a widget (Tasker Task shortcut) to add the button to the screen.