Jimmy’s weblog

1/21/2005

Wake-On-LAN

Filed under: — jimmy @ 8:34 pm

Today I enabled the Wake-On-LAN (WOL) feature on my workstation (Gigabyte nforce2 board). There are a two important things to check, otherwise it won’t work:

  • Enable WOL in the BIOS
  • Check if WOL is enabled on the NIC after booting Linux

My motherboard has an onboard NIC, so I don’t have to use a WOL-cable. But I didn’t know that the BIOS settings for onboard NICs and NICs with attached WOL-cable are different! This page helped me a lot, there’s a lot of information about WOL and how it works. So if you have an onboard NIC you have to enable “Wake on PME”, not “Wake on LAN”!
The next important step is to check the settings of the NIC after Linux has booted and loaded the driver for the NIC. There’s a tool called ethtool to do the job (run as root):

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

“Wake-on: d” means, that WOL is disabled, “Supports Wake-on: g” means, that the NIC supports WOL with magic packets (”man ethtool” for more information about the abbreviations).
So we have to enable WOL, again.

reptile:~# ethtool -s eth0 wol g
reptile:~# ethtool eth0
Settings for eth0:
        Supports Wake-on: g
        Wake-on: g
        Link detected: yes

This change is lost after the next reboot, so we have to make it persistent. I didn’t find any parameter for the forcedeth module to enable WOL, so I just added the command (ethtool -s eth0 wol g) to /etc/init.d/bootmisc.sh.
Now I can start my workstation by executing the following command on another machine:

etherwake -i eth1 00:0D:61:06:EE:DE

To make it a little bit simpler I created the file /etc/ethers, containing this line:

00:0D:61:06:EE:DE reptile

Try “man ethers” for more information.
Now I only have to type:

etherwake -i eth1 reptile

3 Responses to “Wake-On-LAN”

  1. Kir Says:

    Thanks a lot, Jimmy, that helped me to set up WOL on my desktop too. I even wrote a simple shell script, just for fun:

    #!/bin/bash
    # Wake up remote machine
    # Usage: wake HOSTNAME
    # Script relies on HOSTNAME being in /etc/hosts (or its IP resolvable)
    # and /etc/ethers (put its MAC address there)

    HOST=$1
    # Timeout waiting for host to bring up, in seconds
    WAITTIME=60
    # Check interval
    SLEEPTIME=4

    if ping -c1 -W1 $HOST >/dev/null; then
    echo "Host $HOST is already up - exiting"
    exit 0
    fi

    T1=`date +%s`
    echo "Waking up $HOST"
    # MAC address of $HOST should be in /etc/ethers now
    #sudo etherwake -i eth1 00:0c:6e:c2:d8:fe
    sudo etherwake -i eth1 $HOST

    echo -n "Waiting for $HOST to come up "
    while ! ping -c1 -W1 $HOST >/dev/null; do
    echo -n '.'
    sleep $SLEEPTIME
    let C+=$SLEEPTIME
    if test $C -gt $WAITTIME; then
    echo " [FAILED]"
    exit 1
    fi
    done

    T2=`date +%s`
    let DT=T2-T1
    echo ' [OK] (in $DT seconds)'

  2. Hrw website Says:

    Wake on LAN
    http://www.jimmy.co.at/weblog/wp-trackback.php/30

  3. Hrw website Says:

    Wake on LAN
    Few days ago I had to go from work to home just to turn on my desktop computer. Now when I have possibility to remote login to my router I tried to get Wake-On-LAN working.

    My desktop PC has 3 network cards:
    - 3Com 3c905b-tx (my favorite one which I u…

Leave a Reply