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

A LAN connector

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:
  1. create a new script:
    gksudo gedit /etc/init.d/wol.sh
  2. paste this and save the file:
    #!/bin/bash
    ethtool -s eth0 wol g
    exit
  3. 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!

This entry was posted in Linux, Tricks and tagged , , . Bookmark the permalink. Trackbacks are closed, but you can post a comment.

3 Comments