Header Shadow Image


Configuring Wake On LAN (WOL) from Hibernation or Suspend Mode

WOL or in other words Wake On LAN is a feature that allows you to send a magic packet to a machine that is suspended or hibernating (Potentially when it's off as well) to wake that computer up.  This is handy, particularly where you have DD-WRT installed on your router(s) which allows you to send these WOL magic packets from the router CLI or the router GUI.  Here's how we can set this up to allow you to send WOL magic packets from any system on your network, including the routers to wake up your hardware.  This allows you to put your systems to sleep and signal them to wake up when you login remotely.  This saves power and arguably preserves the life of the system.  It is also particularly handy in the absence of technologies such as HP iLO (LOM) which is the HP Lights Out Management processor build into the HP proprietary systems.

One of the first things we need is to get the MAC address of the remote machine we will be waking up.  This is easily enough done with Linux in this manner:

[root@mbpc ~]# ping -c 4 192.168.0.13 && arp -n
PING 192.168.0.13 (192.168.0.13) 56(84) bytes of data.
64 bytes from 192.168.0.13: icmp_seq=1 ttl=64 time=1.84 ms
64 bytes from 192.168.0.13: icmp_seq=2 ttl=64 time=0.198 ms
64 bytes from 192.168.0.13: icmp_seq=3 ttl=64 time=0.238 ms
64 bytes from 192.168.0.13: icmp_seq=4 ttl=64 time=0.182 ms

— 192.168.0.13 ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 0.182/0.616/1.846/0.710 ms
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.0.13             ether   94:de:80:73:b1:78   C                     bond0
192.168.0.1              ether   f8:d1:11:bc:47:8e   C                     bond0
192.168.0.10             ether   48:5d:60:cb:44:1c   C                     bond0
[root@mbpc ~]#

Next, we'll need to get two packages off the web.  In case running yum search wol does not turn up anything, try searching with yum search wake instead:

yum install wol.x86_64
yum install net-tools

This will provide you with a number of packages below:

[root@mbpc ~]# which ether-wake
/sbin/ether-wake
[root@mbpc ~]# which wol
/usr/bin/wol
[root@mbpc ~]# rpm -qf /sbin/ether-wake
net-tools-1.60-110.el6_2.x86_64
[root@mbpc ~]# rpm -qf /sbin/wol
error: file /sbin/wol: No such file or directory
[root@mbpc ~]# rpm -qf /usr/bin/wol
wol-0.7.1-4.el6.x86_64
[root@mbpc ~]#

The utilities will alow for the following commands we'll need to wake up the remote machines.

ether-wake <MAC OF REMOTE>
wol <MAC OF REMOTE>  <NIC>
/usr/sbin/wol <MAC OF REMOTE>         # On DD-WRT Devices (The GUI one might not work)
/sbin/wol -h <IP> <MAC OF REMOTE>     # On DD-WRT Devices (The GUI one might not work)

Before we can use them however, we need to enable the WOL on the network card (NIC) we'll be using.  This is the command to do that with:

ethtool -s eth0 wol g

Here's how it looks like enabled on a NIC on our Linux system:

[root@mbpc ~]# ethtool eth0
Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Speed: 10Mb/s
        Duplex: Half
        Port: MII
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pumbg
        Wake-on: g

        Current message level: 0x00000033 (51)
        Link detected: no
[root@mbpc ~]#

In Windows, this feature can be enabled on the NIC in the following manner from Start – Control Panel – Network and Sharing Center – Click the Wired or Wireless Network – Properties – Configure – Advanced and find Wake on Magic Packet then select Enabled:

Windows WOL Wake On LAN NIC Configuration

For DD-WRT routers, one can setup the WOL feature in this manner to have the router wake up the computers on your network:

DD-WRT WOL Wake On LAN Setup Screen


Use DD-WRT to wake up the computers.  See my config under Administration -> WOL above for configuring the MAC addresses and potentially scheduling.  Before this will work, BIOS needs to be enabled to allow for WOL / Wake on LAN functionality.  Different BIOS manufacturers will allow you to enabel this usually through non intuitive BIOS options (To enter your BIOS, press the DEL key on startup).  Here is a list of some of the more common ones:

Power – APM – PCI/PCI-E – enable
Power – APM Configuration – Power On By PCIE Devices – Enable
Advanced – ACPI Configuration – PCI Devices Power On – Enale
Power Management Setup – PME Event Wake Up – Enable
Power Management Setup – Resume By PCI/PCI-E/Lan PME – Enable
Power Management – Resume by LAN – Enable
Power Management Setup – WOL(PME#) Prom Soft-Off – Enable
Power Management Setup – WOL(RI#) Prom Soft-Off – Enable
Advanced – Onboard LAN Boot ROM – Enable
Power – Power Up On PCI Card – Enable
Intergrated Peripherals – Via Onchip PCI Device – Onboard Lan Boot ROM – Enable
Power Management Setup – IRQ/Event Activity Detect – Resume By PCI PME – Enable

Once enabled, the card should be able to receive magic packets (WOL Signals) to wake up your system.  Without this, any network magic packet will be ignored.  To test this, in this case we'll use one of the Linux systems, put your PC into hybernation or suspend (if you have this feature).  You can also use the PROC filesystem to check in this manner:

cat /sys/power/state

Once the system is put into hybernation, using the SYS filesystem as in the below or through the GUI (Linux KDE / Gnome etc or Windows Suspend / Hybernate): 

echo mem > /sys/power/state

To wake up the computers, all we had to do is issue one of the listed commands above and this woke up the target system.  

TROUBLE:

Inevitably, there'll be some hickups along the way to success.  In our case, we didn't have the coreutils package installed and this gave us this ERROR.  Tracing confirmed the missing package:

[root@moto ~]# echo -n mem > /sys/power/state
bash: echo: write error: No such file or directory
[root@moto ~]# ls -al /sys/power/state                                                                        
-rw-r–r– 1 root root 4096 Jul 17 20:41 /sys/power/state
[root@moto ~]# cat /sys/power/state                                                                                             
mem disk
[root@moto ~]# strace echo -n mem > /sys/power/state                                                                                           
execve("/bin/echo", [“echo”, “-n”, “mem”], [/* 58 vars */]) = 0
brk(0)                                  = 0x9c2e000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb771a000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=227326, …}) = 0
mmap2(NULL, 227326, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb76e2000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 \216\255\0004\0\0\0"…, 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1855556, …}) = 0
mmap2(0xac2000, 1620360, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xac2000
mprotect(0xc47000, 4096, PROT_NONE)     = 0
mmap2(0xc48000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x185) = 0xc48000
mmap2(0xc4b000, 10632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xc4b000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb76e1000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb76e16c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0xc48000, 8192, PROT_READ)     = 0
mprotect(0xabe000, 4096, PROT_READ)     = 0
munmap(0xb76e2000, 227326)              = 0
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=99158720, …}) = 0
mmap2(NULL, 2097152, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb74e1000
mmap2(NULL, 245760, PROT_READ, MAP_PRIVATE, 3, 0x2dc0) = 0xb74a5000
brk(0)                                  = 0x9c2e000
brk(0x9c4f000)                          = 0x9c4f000
mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE, 3, 0x2e19) = 0xb74a4000
close(3)                                = 0
fstat64(1, {st_mode=S_IFREG|0644, st_size=4096, …}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb74a3000
write(1, "mem", 3)                      = -1 ENOENT (No such file or directory)
close(1)                                = 0
munmap(0xb74a3000, 4096)                = 0
open("/usr/share/locale/locale.alias", O_RDONLY) = 1
fstat64(1, {st_mode=S_IFREG|0644, st_size=2512, …}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb74a3000
read(1, "# Locale name alias data base.\n#"…, 4096) = 2512
read(1, "", 4096)                       = 0
close(1)                                = 0
munmap(0xb74a3000, 4096)                = 0
open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = 1
fstat64(1, {st_mode=S_IFREG|0644, st_size=435, …}) = 0
mmap2(NULL, 435, PROT_READ, MAP_PRIVATE, 1, 0) = 0xb74a3000
close(1)                                = 0
write(2, "echo: ", 6echo: )                   = 6
write(2, "write error", 11write error)             = 11
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": No such file or directory", 27: No such file or directory) = 27
write(2, "\n", 1
)                       = 1
exit_group(1)                           = ?
[root@moto ~]# ls -al /usr/share/locale/en_US/LC_MESSAGES/libc.mo
ls: cannot access /usr/share/locale/en_US/LC_MESSAGES/libc.mo: No such file or directory
[root@moto ~]# ls -al /usr/share/locale/en_US/LC_MESSAGES/coreutils.mo
ls: cannot access /usr/share/locale/en_US/LC_MESSAGES/coreutils.mo: No such file or directory
[root@moto ~]#

We could install the package in this manner however in our case we needed to upgrade our Fedora which is discussed in another topic on this blog:

yum search coreutils –skip-broken

coreutils.i686 : A set of basic GNU tools commonly used in shell scripts
Repo        : installed
Matched from:
URL         : http://www.gnu.org/software/coreutils/

 

coreutils-libs.i686 : Libraries for coreutils
Repo        : installed
Matched from:
Description : Libraries for coreutils package.
URL         : http://www.gnu.org/software/coreutils/

Off another system we see the missing files are linked to the coreutils package which we didn't have on this system:

[root@mbpc mnt]# rpm -qf /usr/share/locale/en/LC_MESSAGES/coreutils.mo
coreutils-8.4-19.el6.x86_64
[root@mbpc mnt]#

Good luck!  Hope you found this article helpful.  Feel free to leave a reply on your success story.

Cheers,
TK

 

 

 

 

 

 

 

Leave a Reply

You must be logged in to post a comment.


     
  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License