Enable Wake-On-LAN (WOL) on an Ubuntu PC

Notice: This little tutorial assumes that you have some basic Linux knowledge, and that you know what SSH is.
Christmas is coming, and I’ll be out of office for a while.
I was a little worried because I could need some data from my main desktop PC… I’ll copy the most important documents on the laptop, but if I’ll forget something? I don’t want to leave my desktop turned on, nor to be obliged to pass the evening of 24th of December in my car to come back to the office.
So it’s time to activate Wake On LAN
Wake On LAN (aka WOL) is a feature of many PCs. It leaves the network port in standby mode, without turning off it completely. It requires very little power, and it allows you to activate a PC from your LAN.
In my office network I have a Linux server that is always on: with WOL I can login into this, launch a very simple command to activate my desktop and then login into it to do what I need. When I finish I can also turn it off again: it will remain available to be re-activated later!
I’ll do this from my office server, anyway the same feature (the ability to send a special command to the local network to turn a PC on) is embedded in some good home and office routers, so check yours
- The first action I had to accomplish was to activate WOL from the BIOS of my desktop motherboard (an ASUS M2A-MX). Usually, this option is easy to be found… even it wasn’t so in mine (here the option is called “Resume from S5 by PME#”);
- The second thing is to discover and write somewhere the desktop MAC address. I found it from my router web interface, listing the connected devices… anyway you can read it directly from the PC to be turned on remotely, with ifconfig command. It will list a lot of information about the computer’s network interfaces… usually the LAN card is identified by eth0 code, and the MAC address is in this form: HWaddr xx:yy:zz:01:02:03
- Then I installed a little utility called wakeonlan in my office server (that was already configured to accept remote users login via SSH), with a single terminal command:
sudo apt-get install wakeonlan - At this point, WOL was already working if I turn my desktop on, then I turn it off with its power button. I login into the server via SSH, then I send this simple command:
wakeonlan xx:yy:zz:01:02:03
(just change the MAC address with the one of your target PC) - Unfortunately, it didn’t work turning the desktop off from Ubuntu (with Gnome’s shutdown command), so I needed to create a boot script to activate the feature everytime the PC starts:
- create a new script:
gksudo gedit /etc/init.d/wol.sh - paste this and save the file:
#!/bin/bash
ethtool -s eth0 wol g
exit - give execute permission to this new file and add it to startup scripts:
sudo chmod a+x /etc/init.d/WOL.sh
sudo update-rc.d WOL.sh defaults
It’s ok! Now you’ve only to reboot and shutdown the PC normally, the network interface will remain in standby mode, allowing you to wake the system from any another PC (or router, see above) in the LAN!
December 14th, 2008
nice article, do you know if there something that will auto shutdown when there is no network activity for a certain period of time? I guess what you would also need to know then is whether the computer was turned on using a WOL command or via the power button …
January 29th, 2009
Your visitors from Germany who are looking for a step by step instruction how to set up Wake on LAN on their Apple Macintosh computers should have a look at: http://www.sonoya.com/apple-mac-os-x-anleitung-mit-den-richtigen-einstellungen-fur-wake-on-lan-wol-funktioniert-das-aufwecken-aus-dem-ruhezustand-uber-das-netzwerk-remote-ethernet.html