Laptop in hand, I plunk myself onto my bed ready to do a little coding on one of my various github projects. I attempt to ssh into my desktop machine only to notice that it is asleep. No problem, I pull out my phone, open an app, and push Wake-on-LAN. Computer is once again awake. Now I can ssh into my desktop machine and enjoy a nice evening of coding and working on my various projects.
Wake-on-LAN is a wonderful, yet incredibly annoying to set up, protocol that allows you to wake your computer if it is asleep or off. For me this means that I can happily configure my computer to sleep when it is inactive and I still don’t have to physically turn it back on everytime I want to remotely use it.
So let’s set up Wake-on-LAN.
First, open a terminal on your linux machine and run
$ ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> ... link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo ... inet6 ::1/128 scope host ... 2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> ... link/ether 12:34:56:78:9a:bc brd ff:ff:ff:ff:ff:ff inet 192.168.1.27/24 brd 192.168.1.255 ... ... inet6 xxxx::xxxx:xxxx:xxxx:xxxx/64 ... ... 3: wlp0s20f3: <NO-CARRIER,BROADCAST,MULTICAST,UP> ... link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
Notice section 2 of the output. It lists my MAC address
12:34:56:78:9a:bc, IP address
192.168.1.27, and the name of the network device
enp2s0. We will need this information.
Next check if your network card is set up to accept wake-on-LAN packets. To do this we need to run ethtool with the network device name we retrieved in the previous command (if you don’t run as root it won’t give you the wake-on information):
$ sudo ethtool enp2s0 Settings for enp2s0: … Supports Wake-on: pumbg Wake-on: g …
The important part of the output is the letter “g”. You should see this in both the “supports” and the “Wake-on” sections. If the Wake-on doesn’t have the letter
g you can try to enable it by running
sudo ethtool -s enp2s0 wol g.
Now that the desktop machine is set up we need to configure something to send the Wake-on-LAN request. I use an Android app called PingTools, but there are lots of apps on both Android and iPhone that will do the same thing. In ping tools click on the Wake-on-LAN section of the app, click add, and add a name and type in the MAC address we saw above, for example
Time to test this out. Force your computer to sleep or hibernate then in the app click “wake”, if everything is configured correctly your computer should wake back up. Good, now turn your computer off, click “wake” again, hopefully your computer starts up again. One final test, put your computer to sleep again, click “wake”, did it work? No? If not this is because every time your computer gets fully turned off the network card will reset, meaning you need to rerun
sudo ethtool -s enp2s0 wol g. Now is it working again? Hopefully.
I hope this was useful.
What if you followed the steps above and it still doesn’t work? It isn’t easy to debug Wake-on-LAN, but there are a few other things you can try or at least be aware of.
Is your BIOS set up correctly?
Is your phone on the same network as your desktop?
Is ethtool showing wake-on-LAN enabled?