Turning on computers remotely

Posted by Steve on Wed 20 Apr 2005 at 08:42

To save power it's often useful to turn systems off, but of course when you do that you cannot use them! This is especially frustrating when you turn off a machine which is physically remote from you, but it doesn't need to be. Many modern PCs have the ability to be remotely "woken up" and turned on.

"WakeOnLan" is the term which is used for remotely powering on machines, as this is done by sending "magic network packets" to switch on machines.

To use wakeonlan you'll need either:

  • A network card which supports WakeOnLan, which usually has a jumper which connects to your system's motherboard.
  • An on-board network interface which supports this functionality.

Many modern systems with on-board NICs support wakeonlan, but it must be enabled in the BIOS. (Look for the option in the "power management" section of your BIOS, it might be called "wakeonlan", "netboot", or "wake on ring events").

If you have the requisite hardware support can see if it's enabled by your system by running the ethtool command, this shows whether the wakeonlan option is supported by your card, and whether it is enabled.

If you don't have this installed run:

apt-get install ethtool

Once it's installed run it with the name of your network interface:

root@lappy:~# ethtool eth0
Settings for eth0:
       Supports Wake-on: g
       Wake-on: d
       Link detected: yes

Here we can see that wakeonlan support is available because of the g, but it's disabled. (This is explained in the manpage which you can read with "man ethtool"). To enable the magic packet support run:

root@lappy:~# ethtool -s eth0 wol g

Now you should be able to see that it's turned on:

root@lappy:~# ethtool eth0
Settings for eth0:
       Supports Wake-on: g
       Wake-on: g
       Link detected: yes

Now that you know it's turned on you need to do one more thing. Wakeonlan software requires that you know the MAC address of the machine you wish to switch on, rather than the IP address.

To determine the MAC address you can either:

  • Discover it on the machine itself before it is switched off, by using ifconfig
  • Determine it remotely, whilst the machine is powered on and running.

To determine the MAC address via ifconfig just run it:

skx@mystery:~$ /sbin/ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0A:E6:F6:A3:F4  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::20a:e6ff:fef6:a3f4/64 Scope:Link
          RX packets:2218390 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3098440 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1624008578 (1.5 GiB)  TX bytes:1368310661 (1.2 GiB)
          Interrupt:10 Base address:0xd400 

Here the MAC address is 00:0A:E6:F6:A3:F4, it's on the first line and is described as the "HWaddr" or "hardware address".

If you're looking for the MAC address of another machine upon your LAN you can ping the machine, then look at the arp cache.

For example if I wished to determine the MAC address of the machine sun.my.flat from my current host I'd run the following two commands:

kx@mystery:~$ ping -c 1 sun
PING sun.my.flat ( 56(84) bytes of data.
64 bytes from sun ( icmp_seq=1 ttl=64 time=0.202 ms

--- sun.my.flat ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.202/0.202/0.202/0.000 ms
skx@mystery:~$ /usr/sbin/arp sun
Address                  HWtype  HWaddress           Flags Mask            Iface
sun                      ether   08:00:20:C2:1E:F6   C                     eth0

The arp command shows the machine's MAC address, the ping being required first to make sure that my current machine knew the MAC address in the first place.

Once you have the MAC address you can shutdown the system you wish to test, and then attempt to restart it remotely.

There are several pieces of software for sending the wakeonlan packets inside the Debian archive:

  • etherwake
    • Requires root privileges and available in all Debian distributions.
  • wakeonlan
    • Can be used by all users, but only in the Sarge (testing) and unstable (Sid) repositories

I'm going to use wakeonlan, since it's already installed and can be used by non-root users:

skx@mystery:~$ wakeonlan  08:00:20:C2:1E:F6 
Sending magic packet to with 08:00:20:C2:1E:F6

This sends the magic wake on lan packet to the machine on the LAN with the hardware address "08:00:20:C2:1E:F6" which we previously determined belonged to the machine sun.

If all goes well the machine will begin to boot shortly after recieving the packet.



Posted by Anonymous (213.164.xx.xx) on Thu 21 Apr 2005 at 08:37
This doesn't work for me. WOL is enabled in the BIOS, the network card light is on despite the power being off, I've run ethtool, and it shows everything to be as it should, but both tools can't wake it, even on the same subnet.

[ Parent | Reply to this comment ]

Posted by Anonymous (203.122.xx.xx) on Thu 21 Apr 2005 at 13:25
Did you connect the jumper from the card to the motherboard?

[ Parent | Reply to this comment ]

Posted by Anonymous (213.164.xx.xx) on Fri 22 Apr 2005 at 07:55
It's an onboard Broadcom gigabit card. There don't seem to be any jumpers on the mother board that turn WOL on or off.

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Fri 22 Apr 2005 at 13:07
[ View Steve's Scratchpad | View Weblogs ]

It's very hard to tell why it didn't work - did you perhaps try both of the software tools?

It might just be that the card is expecting something different from what is being sent.

-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by Anonymous (213.164.xx.xx) on Fri 22 Apr 2005 at 14:11
I tried both software tools.
I also specified the ip address if the tool allowed.


[ Parent | Reply to this comment ]

Posted by Anonymous (209.195.xx.xx) on Fri 5 Aug 2005 at 12:02
I had it working before I reinstalled debian, at this point the bios was still set to allow but it would always switch to d. I tried all of the suggestions here including my own additions to no avail. I then left it on g, rebooted into the bios switched it to off, restarted, - into the bios again to switch it on. Powered off. And it worked. Try this is you're at your wits end! I was!

[ Parent | Reply to this comment ]

Posted by Anonymous (195.174.xx.xx) on Fri 22 Apr 2005 at 09:12
# ethtool eth0
Settings for eth0:
No data available

I get this message. What could be the problem?

My NIC is (onboard):
0000:02:05.0 Ethernet controller: 3Com Corporation 3c940 10/100/1000Base-T [Marvell] (rev 12)

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Fri 22 Apr 2005 at 09:14
[ View Steve's Scratchpad | View Weblogs ]

That's strongly indicative of the fact you don't have WOL support, either that or it's not detected by your NIC's driver.

-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by Anonymous (145.7.xx.xx) on Sat 23 Jul 2005 at 09:48
I have the 3Com 3c940 1gbit marvell too. Its an onboard device on the Asus K8V Deluxe for AMD64.

The wake-on-lan feature works just fine when I shutdown windows (hibernate does not work with wol, but shutdown does). When I use the wakeonlan linux tool to power the machine on over network, it works.

But when I powerdown my machine in linux it does not work. I notice the LED on the back of my pc (nic) going off after shutdown in linux (while after shutdown in windows the LED stays on) and thus when I use the wakeonlan tool again, the pc wont respond. Probably because the nic is turned off by linux.

I also get the same message when using ethtool, that it cannot get data from the card. Maybe a driver problem? Ive build it into the kernel by the way, I dont realy like modules.

If anyone finds the solution to this problem, lightware@hotmail.com. thx.

[ Parent | Reply to this comment ]

Posted by Anonymous (199.64.xx.xx) on Fri 3 Feb 2006 at 22:33
I also have the Asus K8V for AMD64 motherboard, WOL works fine with the kernel-image for the k7 but fails WOL with the AMD-64 kernel-image.

[ Parent | Reply to this comment ]

Posted by tibor (128.143.xx.xx) on Fri 17 Nov 2006 at 02:38
I have the Marvell Yukon 1G card on Asus K8V-X. Wake-on-LAN works in Linux after enabling "Wakeup on PCI" in the BIOS and using the ethtool command shown in this article. Awesome.

[ Parent | Reply to this comment ]

Posted by tibor (128.143.xx.xx) on Sun 20 May 2007 at 01:57

Update: I upgraded to a gigabit switch, and Wake-on-LAN no longer works! I suspect it is a Marvell Yukon or an ASUS K8V-X issue. If the already shut down machine is disconnected from the 1000Mbps port and reconnected to a 100Mbps port, wakeup immediately works without any other change. Also, I tested that it is not a switch issue since the magic packet would go through any 1000Mbps links and get delivered as long as the NIC is in 100Mbps mode.

Not so awesome... Anyone encounter this strange problem?

[ Parent | Reply to this comment ]

Posted by Anonymous (88.65.xx.xx) on Wed 7 Nov 2007 at 07:17
I have been trying to make Wake-on-LAN work for three days now. I configured /proc/acpi/wakeup and set the Wake-on proprety using ethtool in my init-scripts but it did not wake up at all.
My NIC is a Marvell 88E8001 controller on a Gigabyte GA-8IPE775 board. I am using Debian etch with kernel 2.6.18 and skge module.
After reading your post, I tried to set the interface-speed to 100Mbps on shutdown. Wake-on-Lan worked fine with that setting.

[ Parent | Reply to this comment ]

Posted by tibor (128.143.xx.xx) on Wed 7 Nov 2007 at 19:05
What is the best way to set the interface-speed to 100Mbps on shutdown?

[ Parent | Reply to this comment ]

Posted by Anonymous (89.203.xx.xx) on Wed 9 Jul 2008 at 23:24
I was reading this thread and had a similar problem using Gigabyte GA-8IPE1000 integrated Lan, loaded through the skge module. I'm using Etch, and thanks for your tip, now my wake-on-lan is working.

In my case, the fix had nothing to do with switching to 100Mbps at halt/shutdown. Just do it any time before sending the magic packet (i.e. using etherwake). Also make sure that autoneg is ON for both machined using "ethtool -s autoneg on".

First, I had to disable the if-down script from turning off the wake-on-lan interface on the target machine. I did this by editing /etc/init.d/networking and changing this line:

if ifdown -a --exclude=lo; then


if ifdown -a --exclude=lo --exclude=eth0; then

Then I ran the following commands from the source machine:

ethtool -s eth2 speed 100 duplex half autoneg on
sleep 4
etherwake -i eth2 12:12:12:12:12:12

And BAM! It worked. I've waited for a while until the other machine is up-and-running then I switched back to using 1000Mb:

sleep 50
ethtool -s eth2 speed 1000 duplex full autoneg on

Thanks again!

[ Parent | Reply to this comment ]

Posted by Anonymous (62.233.xx.xx) on Fri 22 Apr 2005 at 13:00
I have a problem, I write :
ethtool -s eth0 wol g
and I have :
Supports Wake-on: g
Wake-on: g
Link detected: yes
but when I shutdown I can't wakeup computer
When I turn on computer normaly and write :
ethtool eth0
I get:
Supports Wake-on: g
Wake-on: d
Link detected: yes
Where is a problem ? Why it change from "Wake-on: g" into "Wake-on: d" after shutdown ? An why magic packet don't wakeup him ?

[ Parent | Reply to this comment ]

Posted by Steve (82.41.xx.xx) on Fri 22 Apr 2005 at 13:06
[ View Steve's Scratchpad | View Weblogs ]

The ethtool setting must be run each time the machine boots, it is reset when the system brings the interface up.

If you can get it working you could create an init script to do it for you.

Why it's not working I don't know, perhaps the MAC address is wrong, the machine doesnt support it fully, or you need to try using a different software tool.

-- Steve.org.uk

[ Parent | Reply to this comment ]

Posted by Anonymous (207.109.xx.xx) on Tue 3 May 2005 at 20:41
Instead of creating an init script, I add a line to /etc/network/interfaces

iface eth0 inet dhcp
up ethertool -s eth0 wol=g

[ Parent | Reply to this comment ]

Posted by kink (145.99.xx.xx) on Fri 29 Jul 2005 at 16:53
I needed to do that, but I also needed to disable "ifdown" when shutting the computer down. Appearently ifdown puts my nic (a realtek chipset card) into the non-wol-enabled state again.

I edited /etc/init.d/networking and commented out the line
"ifdown -a --exclude=lo" and everything worked.

BTW the article mentions a little cable to connect nic and motherboard; on more recent PC's this is not necessary anmore (or even possible). The system works via PCI and the option in the BIOS might also be labeled "Wake on PCI".

[ Parent | Reply to this comment ]

Posted by kink (145.99.xx.xx) on Mon 1 Aug 2005 at 11:09
BTW, the example in parent contains a typo, should be:

up ethtool -s eth0 wol=g

[ Parent | Reply to this comment ]

Posted by kink (145.99.xx.xx) on Wed 3 Aug 2005 at 19:45
Argh, corrected one typo but left the other, the complete line should be:
up ethtool -s eth0 wol g

[ Parent | Reply to this comment ]

Posted by baruch (149.157.xx.xx) on Fri 26 Aug 2005 at 14:46
One is better to use:
up ethtool -s $IFACE wol g

And then, if like me, your interface is eth2, it will actually work. Even if you change the interface name later.

[ Parent | Reply to this comment ]

Posted by sathiyamoorthy (59.92.xx.xx) on Wed 24 Oct 2007 at 06:48
This is not working.....

while rebooting the network service says error

[ Parent | Reply to this comment ]

Posted by Anonymous (194.138.xx.xx) on Thu 5 May 2005 at 13:48
I am not sure if the package's scripts did anything, but I had this working without any intentional effort on my toshiba satellite S1400-103, by just enabling wake-on-lan in BIOS.

I don't want to brag, just wordering if you're, maybe, doing something wrong.

[ Parent | Reply to this comment ]

Posted by Anonymous (82.181.xx.xx) on Sat 17 Jun 2006 at 18:30
Some things I observed:

I couldn't make wakeonlan work on my local network attached to the eth1 interface.
etherwake -i eth1 did the job.

Everything works pretty much out of the box if you shut down Linux with poweroff etc. as you usually do. But if the ac power is lost while the machine is powered down waiting for wakeup, the wake up-call won't work anymore when the power is restored. The nic:s I guess sometimes seem to reset themselves and have to be set with ethtool again..

[ Parent | Reply to this comment ]

Posted by Anonymous (82.119.xx.xx) on Mon 9 May 2005 at 17:17
I have made simple PHP script to remotely power up entire LAN of computers and to monitor their status.
It displays status of each computer and maintains IP address, MAC address and user-defined computer name in SQL database. You are presented with list of compuetrs together with their status and link to turn on selected computers. You can input IP range to scan for new computers to add to database.
WoL packet is sent in UDP discard datagram, ping is done using UDP ping (because "ping" command has minimal timeout 1 second, which is too much when you have to ping 30 PCs).
It's not is release state, but I can send it to you if you want. Contact me on: marki /at/ onee /dot/ sk

[ Parent | Reply to this comment ]

Posted by marki (82.119.xx.xx) on Tue 15 Nov 2005 at 12:27
Few people have requested this script, so I decided to put it on my homepage - http://www.marki-online.net/WoL/

[ Parent | Reply to this comment ]

Posted by tchatelet (62.147.xx.xx) on Mon 16 Jan 2006 at 18:07
Thks for your help. This works perfectly on a local network. Unfortunatly I have to wake up a computer over internet. I found at http://www.depicus.com/wake-on-lan/woli.aspx a way to wake up my PC over the net and behind a rooter (which accept WOL and redirect it).
I tried a few things with wakeonlan, but I did not succed. I guess the problem is in the subnetmask and the way to send it.

[ Parent | Reply to this comment ]

Posted by dmonty (142.22.xx.xx) on Wed 31 May 2006 at 23:25
Here is a script that reads your /etc/dhcp3/dhcpd.conf file and wakes all computers registered in it by mac address. Use it to wake up all computers on your LAN.
open ( FILE, "/etc/dhcp3/dhcpd.conf" );
while (  ) {
  ($mac) = ($_ =~ /(([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2})/);
  if ( $mac =~ /[a-fA-F0-9]{2}:/ ){
    `etherwake -i eth1 $mac`;
close (FILE);

[ Parent | Reply to this comment ]

Posted by nykau (81.56.xx.xx) on Sun 7 Jan 2007 at 16:38
I'd like to boot up my machine by sending a magic packet to its ethernet interface (eth0), a dlink DFE-550TX, which is supposed to support this functionality. My motherboard (an ASUS P3b-F, the one with one ISA slot) is also supposed to support wol.

I plugged wol cable on ethernet card and motherboard, I set up BIOS so as to make it boot on wol signal (Wake on lan: enabled). When the machine is off, it doesn't boot on any magic packet sent to its interface.

I learned after googleling that my interface had to be set up to listen network and boot up the machine when it hears a magic packet. This should be done with ethtool command.

It looks pretty easy so far; but ethtool fails to set up wol on eth0, and it doesn't display any information about wol when typing "ethtool eth0". Again, google just says that my device simply doesn't supports this functionality.

But according to D-link technicians, it does; furthermore, I bought this card because it indeed supports it (OK, I should have bought a 3com ethernet card). One more element, Ubuntu edgy eft seems to be able to set up wol on this card, since ubuntu's ethtool tels about wol on this device; but I want pure Debian.

One more google session, and I suppose that instead of my device, this is its driver that doesn't support wake on lan. I also read that dlink driver doesn't support wol. By downloading dlink driver, I learned that it is sundance module. I can't compile it but this is not necessary, since it is already compiled, installed and loaded on my debian system. However, there is still no wol.

Maybe it is an option I should give to the kernel when booting, but I can't find any information on what eventual option I could give. Maybe I should recompile my kernel with correct options, which ones ?

I also read that I should install and use sk98lin driver instead of dlink's, but it is already installed, how do I do to setup Debian to make my d-link device to work with it instead of working with sundance ? Is it a good solution ?

Do you have an idea on what happens, on what I can/should do ?

[ Parent | Reply to this comment ]

Posted by Anonymous (62.23.xx.xx) on Tue 19 Jun 2007 at 17:39
Thanks for your article.
It's work.

Now, i wanted to know if it is possible to shutdown a PC remotely.
Yes of course, with SSH.

But, i wanted to do that WITHOUT logging in,
for example : shutdown <MAC ADRESS>

Do you understand ?

[ Parent | Reply to this comment ]

Posted by Anonymous (67.83.xx.xx) on Wed 19 Sep 2007 at 02:37
You can install this card and power PC ON/OFF through your browser:


[ Parent | Reply to this comment ]

Sign In







Current Poll

What do you use for configuration management?

( 113 votes ~ 0 comments )