Přeskočit obsah

Language version

This article also has a Czech version.

TL;DR ✨

Wake on LAN is a network standard that allows a computer to be woken remotely. The requirements for using this feature on the target computer (the one to be woken) are:

WOL works very simply and directly at the Ethernet level, and works best within a local subnet. It therefore does not require DNS or IP addressing.

Wake on LAN is a network standard that allows a computer to be woken remotely. The requirements for using this feature on the target computer (the one to be woken) are:

  • Motherboard support for WOL

  • WOL enabled in the BIOS

  • WOL enabled on the target computer's Ethernet interface

🔍 How Does WOL Work?

WOL works very simply and directly at the Ethernet level, and works best within a local subnet. It therefore does not require DNS or IP addressing.

The Wake-on-LAN implementation uses a so-called "magic packet": a broadcast frame whose payload consists of 6 bytes, all set to 255 (FF:FF:FF:FF:FF), followed by sixteen repetitions of the target computer's MAC address.

🔍 How to Enable WOL

✨ A) BIOS

First, enter the BIOS and check that WOL is enabled. Different manufacturers use different names for WOL and place the setting in different locations. It may be in the Power/Power Management section or in the Configuration section. The manufacturer's documentation should provide more specific guidance.

Below is an example from a Dell Latitude C800.

! Taken from: https://www.howtogeek.com/70374/how-to-geek-explains-what-is-wake-on-lan-and-how-do-i-enable-it/

B) Enabling WOL on the target PC's Ethernet port.

Open a terminal on the machine and run ifconfig (or, more recently, ip addr show):

connectica@NB01:~$ ifconfig

enp0s25: flags=4163 mtu 1500

    ether b4:99:ba:e6:b7:03  txqueuelen 1000  (Ethernet)

    RX packets 2211661 bytes 2534406691 (2.3 GiB)

    RX errors 0 dropped 783 overruns 0 frame 0

    TX packets 1631778 bytes 164757022 (157.1 MiB)

    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    device interrupt 20 memory 0xd7400000-d7420000

lo: flags=73 mtu 65536

    inet 127.0.0.1 netmask 255.0.0.0

    inet6::1 prefixlen 128 scopeid 0x10<host>

    loop txqueuelen 1000 (Local Loopback)

    RX packets 245879 bytes 27583477 (26.3 MiB)

    RX errors 0 dropped 0 overruns 0 frame 0

    TX packets 245879 bytes 27583477 (26.3 MiB)

    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

vmbr0: flags=4163 mtu 1500

    inet 192.168.0.200 netmask 255.255.255.0 broadcast 192.168.90.255

    inet6 fe80::b699:baff:fee6:b703 prefixlen 64 scopeid 0x20<link>

    ether b4:99:ba:e6:b7:03  txqueuelen 1000  (Ethernet)

    RX packets 1034796 bytes 772150816 (736.3 MiB)

    RX errors 0 dropped 12 overruns 0 frame 0

    TX packets 1076814 bytes 116516148 (111.1 MiB)

    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

connectica@NB01:~$ ip addr show

1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

   valid\_lft forever preferred\_lft forever

inet6::1/128 scope host

   valid\_lft forever preferred\_lft forever

2: enp0s25: mtu 1500 qdisc pfifo_fast master vmbr0 state UP group default qlen 1000

link/ether b4:99:ba:e6:b7:03 brd ff:ff:ff:ff:ff:ff

3: vmbr0: mtu 1500 qdisc noqueue state UP group default qlen 1000

link/ether b4:99:ba:e6:b7:03 brd ff:ff:ff:ff:ff:ff

inet 192.168.90.200/24 brd 192.168.90.255 scope global vmbr0

   valid\_lft forever preferred\_lft forever

inet6 fe80::b699:baff:fee6:b703/64 scope link

   valid\_lft forever preferred\_lft forever

connectica@NB01:~$

This identifies the Ethernet port's interface name. On Debian/Ubuntu, the newer naming convention uses the enpXYsZ format (for example, enp0s25); older distributions used ethX (for example, eth0).

For the next steps, install the ethtool package:

sudo apt-get update

sudo apt-get install ethtool

Then display the network adapter details:

connectica@NB01:~$ sudo ethtool enp0s25

[sudo] password for connectica:

Settings for enp0s25:

✨ Supported ports: [ TP ]

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

                        100baseT/Half 100baseT/Full

                        1000baseT/Full

✨ Supported pause frame use: No

✨ Supports auto-negotiation: Yes

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

                        100baseT/Half 100baseT/Full

                        1000baseT/Full

✨ Advertised pause frame use: No

✨ Advertised auto-negotiation: Yes

Speed: 1000Mb/s

Duplex: Full

Port: Twisted Pair

PHYAD: 2

Transceiver: internal

Auto-negotiation: on

MDI-X: on (auto)

✨ Supports Wake-on: pumbg

Wake-on: d

Current message level: 0x00000007 (7)

               drv probe link

The most important part of the output is Supports Wake-on and the letter codes for the supported states that follow it.

The line below shows the network adapter's current state.

✨ Supports Wake-on: pumbg

Wake-on: d

The possible network adapter state codes are summarized below:

p
Wake on PHY activity
u
Wake on unicast messages
m
Wake on multicast messages
b
Wake on broadcast messages
a
Wake on ARP
g
Wake on MagicPacket™
s
Enable SecureOn™ password for MagicPacket™
d
d Disable (wake on nothing).

The goal is to enable remote wake-up of the target PC using magic packets, represented by the letter g. Run:

ethtool -s enp0s25 wol g

Configuring persistent mode:

✨ A) Using /etc/rc.local

According to the author, only this configuration worked on a Dell Latitude E5440 running Ubuntu 12.04.

✨ Edit /etc/rc.local

connectica@NB01:~$ sudo nano /etc/rc.local

sleep 5

ethtool -s enp0s25 wol g

✨ C+XY

✨ Add One Line to /etc/init.d/halt

connectica@NB01:~$ sudo nano /etc/init.d/halt

NETDOWN = no

✨ C+XY

✨ B) Using /etc/network/interfaces

According to the author, only this WOL configuration worked on an HP EliteBook running Debian 9.

Edit /etc/network/interfaces as shown below. Remember to replace enp0s25 with the interface name used by the machine:

post-up /sbin/ethtool -s enp0s25 wol g

    post-down /sbin/ethtool -s enp0s25 wol g

connectica@NB01:~$ cat /etc/network/interfaces

# network interface settings; autogenerated

# Please do NOT modify this file directly, unless you know what

# you're doing.

# If you want to manage parts of the network configuration manually,

# please utilize the 'source' or 'source-directory' directives to do

# so.

# PVE will preserve these directives, but will NOT read its network

# configuration from sourced files, so do not attempt to move any of

# the PVE managed interfaces into external files!

source /etc/network/interfaces.d/*

auto lo

iface lo inet loopback

auto enp4s0

iface enp4s0 inet manual

auto enp0s25

iface enp0s25 inet manual

auto vmbr0

iface vmbr0 inet static

address 192.168.90.200

netmask 255.255.255.0

gateway 192.168.90.1

broadcast 192.168.90.255

bridge-ports enp0s25 enp4s0

bridge-stp off

bridge-fd 0

network 192.168.90.0

dns-nameserver 8.8.8.8

post-up /sbin/ethtool -s enp0s25 wol g

    post-down /sbin/ethtool -s enp0s25 wol g

C) Configuration on Ubuntu 18.04 and Later Using a Background Service

According to the author, only this configuration worked on any machine running Ubuntu 19.10.

✨ Create a Name for the New Service

sudo nano /etc/systemd/system/wol.service

Copy the following content into wol.service and replace enp0s25 with the network adapter's interface name:

[Unit]

Description=Configure Wake On LAN

[Service]

Type=oneshot

ExecStart=/sbin/ethtool -s enp0s25 wol g

[Install]

WantedBy=basic.target

Make the machine recognize the change by running:

sudo systemctl daemon-reload

Then enable the service:

sudo systemctl enable wol.service

And start it with:

sudo systemctl start wol.service

Sending a WOL Command from a Mobile Phone or Another Machine

To send a command that wakes the machine remotely, the MAC address of the interface that will receive the magic packet is required. The MAC address is shown in the output of ifconfig or ip addr show.

When using ifconfig, the MAC address appears after ether beneath the interface name:

connectica@NB01:~$ ifconfig

enp0s25: flags=4163 mtu 1500

    ether b4:99:ba:e6:b7:03  txqueuelen 1000  (Ethernet)

When using ip addr show, the MAC address appears after link/ether:

2: enp0s25: mtu 1500 qdisc pfifo_fast master vmbr0 state UP group default qlen 1000

link/ether b4:99:ba:e6:b7:03 brd ff:ff:ff:ff:ff:ff

🐧 Debian/Ubuntu

Install wakeonlan on the source machine:

sudo apt update

sudo apt-get install wakeonlan

Then wake the remote computer with:

wakeonlan b4:99:ba:e6:b7:03

🌐 MikroTik

To turn on a home PC through MikroTik, enter the following on the command line:

tool wol interface=ether1 mac=b4:99:ba:e6:b7:03

The syntax includes the interface (ether1) to which the magic packet is sent and where the target machine is expected to be connected, as well as the target device's MAC address.