Steps to setup wake up on lan on a remote PC
I have a local PC with a GPU which I use to run machine Learning models and some heavy processing (building release version of Android App). It only has a LAN port and is kept near to the router which is not next to my working desk. I us ethis system via ssh into it and shut it down when i’m not using it (save energy).
I have to move my chair or get up and go to the system(5 steps way) to switch it on and I’m nor thrilled to do that plus I can’t automate stuff vai tasker or IFTT due a physical step.
I observed that even when I shutdown the system the LED on the LAN port was glowing and after doing some research found that we can switch on the system remotely even if it is off.
Wake on Lan (WOL) to the Rescue
Using Wake on Lan you can switch on a system even when it is turned off. Given its plugged in and connected to the router/switch.
Server/PC configuration: Ubuntu 18.04 LTS
ip a//get the ip broadcast and mac address for the interface ex: eno1 in my case
sudo ethtool -s eno1 wol g//if not installed get it from apt
- Create a service for WOL so that it persists across restarts
sudo vi wol.service
use the code below replace eno1 with the correct interface name
[Unit] Description=Configure Wake-up on LAN [Service] Type=oneshot ExecStart=/sbin/ethtool -s eno1 wol g [Install] WantedBy=basic.target
- Make the Service start with system
systemctl daemon-reload systemctl enable wol.service systemctl start wol.service
On the Laptop or other PC side
I use MacBook so I installed
wakeonlan from homebrew to send the magic packet to wake the system. There are multiple tools for systems and even simple python script which do the same.
- Install wakeon lan
brew install wakeonlan
- run the command
wakeonlan -i 192.168.0.255 -p 7 xx:xx:xx:xx:xx:xx
- Optional add the above to an alias to make it easy to use
- IP is not the system IP instead it is the broadcast address
- port is by default 7
- xx:xx:xx:xx:xx:xx = mac address of the remote system
Thats it, now I can sit on my chair for hours together. Which in the hindsight is not good for my back.