You are here

Howto: Wake on LAN with ASUS P5WDG2 WS Pro in Debian/Ubuntu

This article from Lifehacker: Access Your Computer Anytime and Save Energy with Wake-on-LAN reminded me that I've been meaning to write this up for a long time.

Before building my latest system I spec'd it out with everything I needed, including Wake On Lan. For my system, I chose the ASUS P5WD WS Pro (other ASUS boards probably have identical setups). Since this new system was going to be a beast and my main file server, I wanted to be able to access it remotely and not have it running 24x7. So WOL is the perfect solution, right? What I didn't know was that different manufacturers define WOL (Wake On Lan) differently. Some of them don't even support wake on lan like you'd imagine (to some, WOL means wake from suspend mode, not from power off). Some manufacturers require a specific UDP port is used when you send the "magic" WOL packet. Lastly I had no idea that operating system support also varies, and IS important.

I'm also using Marvell ethernet controllers, so other Marvell chips might also have the same WOL configuration.

First, you must set the correct BIOS settings (I forget now if only one or both of these are necessary - either way, enabling both doesn't hurt):
Advanced->Onboard Devices Configuration-> PCI-E LAN BOOTROM -> Enable Advanced->Onboard Devices Configuration-> PCI LAN BOOTROM -> Enable

Overview:

  1. Everytime the computer boots, you must tell the ethernet controller(s) to WOL (this is not enabled by default).
  2. When the computer shuts down, you must tell the halt script not to bring down the network controller(s).
  3. Get the ethernet interface's MAC (Hardware) address. After you turn your computer off, send a magic packet to your subnet and your computer will turn itself on.

In Detail:

1. Enable WOL in your ethernet controller (These instructions are also here).

You must have ethtool installed for this: sudo apt-get install ethtool

cd /etc/init.d/ sudo vim wakeonlanconfig

*Or substitute vim for the editor of your choice

In this file, you will paste the following, changing "eth0" to your applicable interface. If you have multiple, just add more lines.

#!/bin/bash ethtool -s eth0 wol g

Now install this script:

sudo chmod a+x wakeonlanconfig sudo update-rc.d -f wakeonlanconfig defaults

Finally, run it:

sudo /etc/init.d/wakeonlanconfig

You can verify this is working by running ethtool:

sudo ethtool eth0

Among other information, you should see this:

Supports Wake-on: pg Wake-on: g

2. Keeping your network interface alive when your computer shuts down:

sudo vim /etc/init.d/halt

Change this line: "halt -d -f -i $poweroff $hddown"
to this: "halt -d -f $poweroff $hddown"
(just remove the -i).

3. Get your MAC Address and send a magic packet.

Your MAC Address is your physical network address and it shows up in the form AB:CD:EF:GH:IJ:KL. Find yours by typing:

ifconfig |grep HW

Now shut down the computer which is getting woken up:

sudo shutdown -h now

From another computer on the same network (another linux computer in this example):

wakeonlan AB:CD:EF:GH:IJ:KL

Your computer should roar to life.

Appendix A: ASUS Tech Support

While not strictly relavent to this tutorial, I just wanted to note that ASUS Technical Support sucks. While I was struggling to get this working not only could technical support not answer my technical questions regarding their implementation of WOL, which vary from vendor to vendor, but they had a horrible attitude and they treated me like I was a moron. That might be true, but as a paying customer I expect humane treatment.

Comments

Does the computer doing the waking have to be on the same network? Or can you send the magic packet from the internet? I'm not a network guru, and am not really sure how a hardware address packet would get routed, but it be nice if I could wake my server up from work.

You can send the magic packet from anywhere on the internet.

In my own particular setup, this site (dimmeria.com) runs on a webserver which runs 24x7. I can ssh into my server and send a magic packet over the local network to wake up the file server.

If you don't have a computer running 24x7 on your local network you can configure your router to port forward all UDP 9 (the default WOL port on most controllers) to your IP address, or to the broadcast address (255.255.255.255). 

It works like a charm.
Many thanks!

Happy to help!

You forgot one thing : set /etc/init.d/wakeonlanconfig executable


chmod +x /etc/init.d/wakeonlanconfig

Thanks for this tip !

Thanks. This was exactly what I needed, though I had to make wakeonlanconfig executable.

Hey, tnks for the article!

i had tried before and couldn't get it working, i was missing the OS configuration, i also have an ASUS motherboard (P5N-E)