Updated 10 August 2019

Wake-On-Lan is a technology that allows a computer to be turned on or awakened by a network message.

Slave computer requirements

  • ATX power supply, Wake-On-Lan compatible motherboard
  • Wake-On-Lan compatible network adapter
  • known MAC address of the network adapter

Host computer requirements

  • special software able to send Magic Packet

How it works

The slave computer is on stand by and supplies power to the mains adapter. The AC adapter is in low-power mode, browsing all packets coming to its MAC address without answering them. If one of them turns out to be a Magic Packet, the network adapter gives a signal that will turn on the computer power.

How to make it work

First enable WoL support in the slave computer BIOS. It can be a point of the same name like Wake On Lan Enable, or Power On By PCIE. It is also possible that this mode is not changed in the BIOS, while the motherboard supports it by default.

To decide whether a WoL network card supports it, boot the slave computer and type:

ethtool eth0
Settings for eth0:
        Supported ports: [ 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: 1000Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 1
        Transceiver: external
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: d
        Link detected: yes

Look at the Supports Wake-on and Wake-on lines. The first displays the available wake modes of the network adapter (+g stands for wake via Magic Pocket), and the second the current mode (d+ stands for disabled WoL).

To put the NIC in WoL mode, type:

ethtool -s eth0 wol g

To enable WoL, run:

ethtool -s eth0 wol d

The network adapter can support saving its status, but it can also reset (usually to d+). Therefore, you should set the necessary mode every time you start WoL.

Add WoL activation to all network adapters that support this technology:

preup() {
   if ethtool $1 | grep "Supports Wake-on:" | grep g >/dev/null;
       ethtool -s $1 wol g

To obtain the network adapter MAC on the slave, run the following on it:

ifconfig -a
        inet  netmask  broadcast
        inet6 fde1:92f6:649a:0:724d:7bff:feb7:406e  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::724d:7bff:feb7:406e  prefixlen 64  scopeid 0x20<link>
        ether 00:01:02:03:04:05  txqueuelen 1000  (Ethernet)
        RX packets 4129968  bytes 1885750720 (1.7 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2068548  bytes 985677562 (940.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xf7000000-f7020000

or either, to display the ARP cache on the host:

Address                  HWtype  HWaddress           Flags Mask            Iface                 ether   00:01:02:03:04:05   C                     eth0                 ether   06:07:08:09:0a:0b   C                     eth0                 ether   0c:0d:0e:0f:10:11   C                     eth0

To ensure that all computers in the network are cached, you can use the nmap tool, which pings the computers in the network and have their MAC addresses cached:

nmap -v -Sp

To wake a computer, run wol on the host:

wol MAC

If you are working with an application, please note that not all computers are switched on immediately after being connected to the mains. This is because at first startup, there was no init when the NIC is powered (). Therefore, it is necessary to make one pre-start manually. If you need to avoid this (for example, if the server is locked or is located at a long distance), you should set the Wake After Power Fail+ parameter to ON in the BIOS.