# [HOWTO] wakeonlan

## anigel

Nowadays, most of our computers do support the wake-on-lan feature (called WOL), which allows you to "wake up" a computer from network. Very practical to save power, with possibility to work from away, without keeping your computer up always.

A relatively recent work has been done on this problem, which bring a nearly perfect support for this feature (I didn't encounter any problem anyway), directly in the init scripts of our loved distribution. I'll try to help you this way !

1. Preparation

First, you must own compatible hardware, and set the wake-on-lan feature in your BIOS (it's often called "Power on PCI Device", or "Wake on PCI Device"). Some older PCI cards need to be conected to your mainboard, using a 3 connector special cable, not very expensive. Check your hardware's documentation.

2. Upgrade your baselayout

Stable version of sys-apps/baselayout is now > 1.12. Feel free to jump to next step, the following is just for remind purpose.

We will have to upgrade baselayout to at least version 1.12.x ; take care, this is a really essential package :

```
echo "sys-apps/baselayout ~x86" >> /etc/portage/package.keywords

emerge baselayout -uDNav
```

The upgrade should be fast. Then, take care to your config files updates : 2 files require to be updated correctly, for WOL to work : /etc/conf.d/rc and /etc/init.d/shutdown.sh. If you already had made custom changes to theses files, just take care to integrate new features in the merger file.

3. Configuration

Now, let's edit /etc/conf.d/rc, and more particularly the RC_DOWN_INTERFACE, which should be "no", to prevent Linux to completely shutdown the network chip on poweroff. Instead, it will let it in a sort of "sleeping state" :

```
# RC_DOWN_INTERFACE allows you to specify if RC will bring the interface

# compeletly down when it stops. The default is yes, but there are some

# instances where you may not want this to happen such as using Wake On LAN.

RC_DOWN_INTERFACE="no"
```

The last step to configure WOL is to ask the network card to react to "magic packets" (the network packets which will bring your computer up). In order to do this, I use ethtool.

```
emerge ethtool -av
```

As soon as emerge finished, you can ensure that WOL is available for your card in Linux with the next command line :

```
ethtool eth0
```

If you get something like "Cannot get driver information: Operation not supported", than you probably won't be able to get WOL working on this card. Sorry.

If you are a bit more lucky, you will get something like this :

```
Settings for eth0:

        Supported ports: [ TP MII ]

        Supported link modes:   10baseT/Half 10baseT/Full

                                100baseT/Half 100baseT/Full

        Supports auto-negotiation: Yes

        Advertised link modes:  10baseT/Half 10baseT/Full

                                100baseT/Half 100baseT/Full

        Advertised auto-negotiation: Yes

        Speed: 100Mb/s

        Duplex: Full

        Port: MII

        PHYAD: 1

        Transceiver: internal

        Auto-negotiation: on

        Supports Wake-on: pg

        Wake-on: d

        Current message level: 0x000000c5 (197)

        Link detected: yes
```

The line "Supports Wake-on: pg" confirms that the card should be able to wake up by network ring. We must just remember to launch ethtool each time the machine is stopped, before shutdown, to ensure that the network chip will be in "wait" mode.

```
echo "ethtool -s eth0 wol g" >> /etc/conf.d/local.stop
```

The "server" side is nearly completed. Before rebooting, just take care to write down your MAC Address. We will need it to wake up your womputer from another machine. This is the 6 hexa digits following "HWaddr" when you run ifconfig.

```
ifconfig

eth0      Link encap:Ethernet  HWaddr 00:75:F2:7E:15:B9

          inet addr:xxx.xxx.xxx.xxx  Bcast:xxx.xxx.xxx.255  Mask:255.255.255.0

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:25859 errors:0 dropped:0 overruns:0 frame:0

          TX packets:12172 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:35119097 (33.4 Mb)  TX bytes:937123 (915.1 Kb)

          Interrupt:16
```

In my case : 00:75:F2:7E:15:B9.

Now, reboot your machine, and then you can shutdown it.

4. Wake-up ! Time for breakfast !

You need another piece of software to send "magic packet" on the network. I personnaly use wakeonlan, but any other WOL software should be able to do this job, even from other OS.

```
emerge net-misc/wakeonlan -av
```

5. Let' test !

Pray, and just launch wakeonlan, followed by the MAC address you just wrote a few minutes ago.

```
wakeonlan 00:75:F2:7E:15:B9
```

And, hopefully, your computer should wake up and boot.

PS : My english is far from perfect, I hope this document is clear enough. Feel free to comment it, it can always be improved  :Wink: .

EDIT (2006-09-10) : Added the ethtool test, to ensure that both card and its driver do support WOL.

----------

## !equilibrium

thanks very much, very useful !!

----------

## rkaerner

 *anigel wrote:*   

> Then, take care to your config files updates : 2 files require to be updated correctly, for WOL to work : /etc/conf.d/rc and /etc/init.d/shutdown.sh.

 

Hello anigel.

Before I start to give my machine a not stable baselayout just let mes ask what kind of change in the second file has to be done. YOu named this file in the quoted sentence, but ou never came back to this file in your clearly structured howto.

thanks and regards,

Ralph

----------

## htranou

I guess the change has been moved to local.stop instead of editing directly shutdown.sh

----------

## anigel

 *rkaerner wrote:*   

> Before I start to give my machine a not stable baselayout just let mes ask what kind of change in the second file has to be done. YOu named this file in the quoted sentence, but ou never came back to this file in your clearly structured howto.

 

Hi,

In fact, the new shutdown.sh script was changed to take care of the new option added to /etc/conf.d/rc: RC_DOWN_INTERFACE. If we set this option to "no", then the new shutdown script will remove the -i option of the halt command, used to properly poweroff your system. This option poweroff the network card too, but we don't want to  :Wink:  .

In fact, I didn't came back on this file, since there is just no modification to do in it. You just have to take care to install the new version, coming with the new baselayout, and that's all !

Thanks for your input,

----------

## hardcore

Great Howto!

As an aside, does anyone know how to wakeup by ip address?

----------

## vanten

Yeah thanks for a great howto. a RWU wiki would be great. IF this shouldent work from a remote network

----------

## hardcore

 *hardcore wrote:*   

> Great Howto!
> 
> As an aside, does anyone know how to wakeup by ip address?

 

After looking around, the answer is to use a static ip address to the wol nic, then forward a port to port 9 on the nic.  Hope this helps anyone else with the same question.

----------

## gtbX

Nice Howto

A note to forcedeth users (nForce built in ethernet): due to a bug in the forcedeth driver, you need to reverse the order of your MAC address when you run wakeonlan:

```
wakeonlan B9:15:7E:F2:75:00
```

 if your MAC address is 00:75:F2:7E:15:B9.  Hopefully this will be fixed in newer kernels

http://www.nvnews.net/vbulletin/showthread.php?t=70384

----------

## bilco105

I don't beleive this works over the internet does it?

----------

## rkaerner

Well I'm not sure, because it doesn't work for me. I did everything in this howto, put the WOL-Cable on my nic and take a look at my BIOS... but nothing happens inside my LAN. Maybe I need to change from a 10Mbit-Hub to a switch or something like that.

To wol a computer via Internet you must forward the ports that are needed to the computer you want to wake up directly. Me, myself and I configured the router in my LAN to be connectable via external login via ssh. Connected to my router from everypoint of the world, I just have to start the wakeup. Should work, because I'm in my LAN in that moment. 

My only problem at the moment is that I don't know where to search the failure. My client seemes to be okay, from technical view everything is done to get waked up. Could be my hub, could be the halfduplex on the card, could be the card or the bios.

Maybe someone with older equipment could give me a hint.

Pentium III Coppermine 733 MHz

D-Link (via-rhine chipset) working on halfduplex

10 MBit hub 10Base-T with possibility to use 10Base-2)

Fritz!Box phone (patched and useable with ssh, wakeonlan an something more)

----------

## wah

Wonderful How-To!  I have been looking for something similar for a while, and this just happened to be the key!  Thanks!

 *gtbX wrote:*   

> Nice Howto
> 
> A note to forcedeth users (nForce built in ethernet): due to a bug in the forcedeth driver, you need to reverse the order of your MAC address when you run wakeonlan:
> 
> ```
> ...

 

I have a forcedeth NIC in my Abit-Fatality-AN8-SLI board, and I do not have to flip the MAC for WOL - I am using gentoo-sources-2.6.16-r9 (AMD64).  So I can verify at least in that kernel version it works properly.

Cheers,

W.

----------

## gtbX

Thats odd.  I just tried it again on my Gigabyte K8N-Pro, and it still needs the reversed order.  (Using gentoo-sources-2.6.16-r13, 64bit)

----------

## wah

 *gtbX wrote:*   

> Thats odd.  I just tried it again on my Gigabyte K8N-Pro, and it still needs the reversed order.  (Using gentoo-sources-2.6.16-r13, 64bit)

 

Hmmm...I just checked the specs on our two boards and they're similar, but on the LAN section yours indicates:

```

CICADA8201 Gigabit LAN PHY chip

```

Where mine reads 

```

NVIDIA Gigabit Ethernet via NF4 Ultra

```

Both run on the NF4 chipset, so I'm not too sure what the difference is here.  That is definitely odd.

W.

----------

## lucida

encounter same problem recently. 

2.6.17-r6 x86

DFI LanPary Ultra-D(NF4 Ultra)

I have to use the reversed mac to wake the computer.

----------

## anigel

 *bilco105 wrote:*   

> I don't beleive this works over the internet does it?

 

Sorry for the delay of my answer (holidays, etc...  :Wink: ).

Theorically, WOL is able to work on any protocol. I mean, you can encapsulate th magic packet in any kind of stream. The trick, to get wol working through the net, is to choose an unused tcp port, on your router / firewall (for instance TCP/60000), and set up things to forward everything arriving from the net on this port, directly to your workstation.

Then, you must find a magic packet generator able to put the magic packet inside a data stream, and send it to your workstation, using your IP, and the chosen TCP port. This way, your workstation should receive the signal, and just wake up.

But (yes, there is a "but"...), I can't tell you more on this subject, since I didn't practice this implementation of WOL.

----------

## heavyt

If you want it  to work over the internet and you have a router (with DD-WRT frimware) then read this howto wiki       How to set up remote WOL (Wake On LAN)

----------

## RayVad

Stil not functioning here.

I got two systems with Intel Pro 100 onboard network cards(both WOL support enabled in BIOS). Both using the e100 module.

Both can't be started from WOL, except when switched-off before completely shutdown or removing the powercord.

Both systems are using a N440BX(PIII- 500Mhz) chipset:

00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX  82443BX/ZX/DX Host bridge (AGP disabled) (rev 03)

00:0d.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 (rev 37)

00:0d.1 SCSI storage controller: LSI Logic / Symbios Logic 53c875 (rev 37)

00:0f.0 Ethernet controller: Intel Corporation 82557/8/9 [Ethernet Pro 100] (rev 05)

00:12.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 02)

00:12.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)

00:12.2 USB controller: Intel Corporation 82371AB/EB/MB PIIX4 USB (rev 01)

00:12.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 02)

00:14.0 VGA compatible controller: Cirrus Logic GD 5480 (rev 23)

Anyone?

rkaerner: Did you find a solution?

----------

## anigel

 *RayVad wrote:*   

> I got two systems with Intel Pro 100 onboard network cards(both WOL support enabled in BIOS). Both using the e100 module.
> 
> Both can't be started from WOL, except when switched-off before completely shutdown or removing the powercord.

 

Sorry : I tried this on a server, with e100 network chip, and I get the same results. Seems that WOL isn't supported yet on this card.

----------

## RayVad

To bad to hear  :Sad: 

But i'll try another NIC (3com) in it with a cable and see if that works. Will let you know.

Is there another driver to use instead of the e100?

----------

## glin

Hi, thanks for great how-to.

WOL now works if I normaly (e.g. shutdown -h now) turn off my computer. I don't even have to use "ethtool -s eth0 wol g" command and it still work.

Problem is, that I usualy use suspend2 suspend to disk (hibernate), and after hibernate, WOL dosn't work  :Sad: .

I tried PowerDown method 4 and 5. I tried add following to common.conf in /etc/hibernate:

```
OnSuspend 20 /usr/sbin/ethtool -s eth1 wol g
```

(yes, I use eth1, not eth0, it's not typo)

The lines in common.conf for Down interface are commented:

```
### network

# DownInterfaces eth0

# UpInterfaces auto
```

And still WOL after hibernate doesn't work.

I use hibernate-script-1.93-r4 and suspend2-sources-2.6.17-r5.

Any suggestion how to make WOL work after hibernate?

----------

## moe

@glin Ive had the same problem, and in my setup wol is only working if I stop the interface:

```
### network 

DownInterfaces eth0 

UpInterfaces auto
```

My ethernetcard is an Intel Pro 100 (e100), which is onboard..

HTH Maurice

----------

## glin

 *moe wrote:*   

> 
> 
> ```
> ### network 
> 
> ...

 

This doesn't work for me   :Sad: 

----------

## RayVad

 *Quote:*   

> 
> 
> My ethernetcard is an Intel Pro 100 (e100), which is onboard
> 
> 

 

Same here. 3 machines all with Intel Pro100 (Ethernet controller: Intel Corporation 82557/8/9 [Ethernet Pro 100] (rev 05)) networkcards onboard. Seems to be impossible to get those onboard cards to work with WOL. Although it should be supported.

Anyone got such cards working with WOL?

All 3 boards got 440BX chipsets (Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (AGP disabled) (rev 03))

----------

## Dun

```

slave ~ # lspci

00:00.0 Host bridge: Intel Corporation 82845 845 (Brookdale) Chipset Host Bridge (rev 11)

00:01.0 PCI bridge: Intel Corporation 82845 845 (Brookdale) Chipset AGP Bridge (rev 11)

00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev 05)

00:1f.0 ISA bridge: Intel Corporation 82801BA ISA Bridge (LPC) (rev 05)

00:1f.1 IDE interface: Intel Corporation 82801BA IDE U100 (rev 05)

00:1f.2 USB Controller: Intel Corporation 82801BA/BAM USB (Hub #1) (rev 05)

00:1f.3 SMBus: Intel Corporation 82801BA/BAM SMBus (rev 05)

00:1f.4 USB Controller: Intel Corporation 82801BA/BAM USB (Hub #2) (rev 05)

02:06.0 Ethernet controller: Intel Corporation 82557/8/9 [Ethernet Pro 100] (rev 0d)

02:07.0 Ethernet controller: Intel Corporation 82557/8/9 [Ethernet Pro 100] (rev 0d)

02:08.0 VGA compatible controller: ATI Technologies Inc Rage XL (rev 27)

```

Wake On Lan works out of the box without any change in /etc/conf.d/rc file. 

Moreover if I set RC_DOWN_INTERFACE to no WakeOnLan doesnt work anymore. Dont know why  :Smile: 

Cya!

[update] Driver compiled statically - Kernel version: 2.6.18-r6

----------

## RayVad

Dun,

What more should there be configured in  /etc/conf.d/rc for the NIC except RC_DOWN_INTERFACE="yes" ?

There was no RC_DOWN_INTERFACE= in the rc file here, so i added it.

Will try WOL later.

----------

## anigel

 *Dun wrote:*   

> Wake On Lan works out of the box without any change in /etc/conf.d/rc file. 
> 
> Moreover if I set RC_DOWN_INTERFACE to no WakeOnLan doesnt work anymore. Dont know why 

 

Lucky ! But I don't know why. I can only try to guess...

This must probably be related to your cards "hard defaults". I remember that on some 3COM PCI cards, a little utility allowed the user to set "hardware behaviour" against WOL : after that, the card WOL-bit was set at every boot-time, during the card initialisation. Maybe your BIOS / hardware revision works like this ?

----------

## Yukimura

I'm also using forcedeth but I can't even get my PC to wake up.

Maybe I'm doing something wrong but I can't see my mistake. 

My ethtool eth0 gives me this:

 *Quote:*   

> Settings for eth0:
> 
>         Supported ports: [ MII ]
> 
>         Supported link modes:   10baseT/Half 10baseT/Full
> ...

 

Also I have set RC_DOWN_INTERFACE to no.

What more should I do?

Kind regards

----------

## anigel

Wel... Maybe this post can help you ?

If not, I just don't have any idea, sorry.

----------

## Yukimura

It seems the problem was in wakeonlan utility. I installed etherwake on my linux router and now it works.

BTW really good how to (simple, and quick to do)  :Wink: 

Kind regards.  :Smile: 

----------

## alex.blackbit

i noticed that there is a little tripwire in the WOL thing.

even if the two machines are on the same subnet it can be mandatory to specify the -i option of wakeonlan.

i believe this is the case when the box which is sending the magic packet has multiple network connections, which is the case on my gentoo internet gateway.

in my case

```
wakeonlan -i 192.168.0.255 -f xeon_mac
```

did the trick.

----------

## Devport

Is there a way to detect if the system has been started threw wakeonlan ? I only want to start ssh on wakeonlan.

----------

## Yukimura

To check that out, I connect on my machine through ssh.  :Smile: 

----------

## RayVad

OK, got it solved!

I used another NIC again(with WOL cable), not the onboard one, to receive the wol packed (yes, got 2 NIC's because its a VPN server) and only APM, not ACPI!

Well, these are my configs:

Did NOT compile ACPI into kernel 2.6.20-r8, only enabled APM, nothing more!

[*] Power Management support │ │

│ │ [ ] Legacy Power Management API (DEPRECATED) │ │

│ │ [ ] Power Management Debug Support │ │

│ │ [ ] Driver model /sys/devices/.../power/state files (DEPRECATED│ │

│ │ [ ] Software Suspend │ │

│ │ ACPI (Advanced Configuration and Power Interface) Support --│ │

│ │ APM (Advanced Power Management) BIOS Support ---> │ │

│ │ CPU Frequency scaling ---> │ │

│ │

[ ] ACPI Support

<*> APM (Advanced Power Management) BIOS support │ │

│ │ [ ] Ignore USER SUSPEND │ │

│ │ [ ] Enable PM at boot time │ │

│ │ [ ] Make CPU Idle calls when idle │ │

│ │ [ ] Enable console blanking using APM │ │

│ │ [ ] RTC stores time in GMT │ │

│ │ [ ] Allow interrupts during APM BIOS calls │ │

│ │ [ ] Use real mode APM BIOS call to power off

Compiled the drivers of the NIC as module in the kernel.

/etc/conf.d/rc: RC_DOWN_INTERFACE="yes"

/etc/init.d/shutdown.sh: Just default!

Installed ethtool to set the WOL parameter on g

Added "ethtool -s eth0 wol g" to /etc/conf.d/local.start and, to be sure, to /etc/conf.d/local.stop

And Voila! it works!!!

Okay, some new issue.... to be fixed later... it starts spontanious now as it happens 3 times. Strange...but WOL works and will find out about this spontanious boot later and report here.

----------

