Hardware settings

The target computer's motherboard and Network Interface Controller have to support Wake-on-LAN. The target computer has to be physically connected (with a cable) to a router or to the source computer, wireless cards do not support WoL.

The Wake-on-LAN feature also has to be enabled in the computer's BIOS. Different motherboard manufacturers use slightly different language for this feature. Look for terminology such as "PCI Power up", "Allow PCI wake up event" or "Boot from PCI/PCI-E".

It is known that some motherboards are affected by a bug that can cause immediate or random wake-up after a shutdown whenever the BIOS WoL feature is enabled (as discussed in this thread for example). The following actions in the BIOS preferences can solve this issue with some motherboards:

Disable all references to xHCI in the USB settings (note this will also disable USB 3.0 at boot time)

Disable EuP 2013 if it is explicitly an option

Optionally enable wake-up on keyboard actions

Note: There are mixed opinions as to the value of #3 above and it may be motherboard dependent.

Software configuration

Enable WoL on the network adapter

Depending on the hardware, the network driver may have WoL switched off by default.

To query this status or to change the settings, install ethtool, determine the name of the network interface, and query it using the command:

The $name placeholder will be replaced by the value of the NAME variable for the matched device.

Note: The name of the configuration file is important. Due to the introduction of persistent device names in systemd v197, it is important that the rules matching a specific network interface are named lexicographically after 80-net-name-slot.rules, so that they are applied after the devices gain the persistent names.

Warning:udev will match the device as soon it becomes available, be this in the initramfs (before the switch_root) or the main system. The order is not deterministic; there is no guarantee. Be sure that your initramfs includes the necessary udev rules (from /etc/udev/rules.d) and supporting binaries (/usr/bin/ethtool).

cron

A command can be run each time the computer is (re)booted using "@reboot" in a crontab. First, make sure cron is enabled, and then edit a crontab for the root user that contains the following line:

On the same LAN

If you are connected directly to another computer through a network cable, or the traffic within a LAN is not firewalled, then using Wake-on-LAN should be very easy since there is no need to worry about port redirects.

In the simplest case the default broadcast address 255.255.255.255 is used:

$ wol target_MAC_address

To broadcast the magic packet only to a specific subnet or host, use the -i switch:

$ wol -i target_IPtarget_MAC_address

Tip: If you intend to continue using Wake-on-LAN, it is recommended to assign a static IP address to the target computer.

Across the internet

When the source and target computers are separated by a router, Wake-on-LAN can be achieved via port forwarding. The router needs to be configured using one of these two options:

Forward a different port to each target machine. This requires any target machine to have a static IP address on its LAN.

In both cases, run the following command from the source computer to trigger wake-up:

$ wol -p forwarded_port -i router_IPtarget_MAC_address

Forward a port to the broadcast address

Most routers do not allow to forward to broadcast, however if you can get shell access to your router (through telnet, ssh, serial cable, etc), you can implement this workaround:

$ ip neighbor add 192.168.1.254 lladdr FF:FF:FF:FF:FF:FF dev net0

(The above command assumes your network is 192.168.1.0/24 and uses net0 as network interface). Now, forward UDP port 9 to 192.168.1.254. This has worked for me on a Linksys WRT54G running Tomato, and on the Verizon FIOS ActionTec router.

Troubleshooting

Random wake up after shutdown

It is known that some motherboards are affected by a bug that can cause immediate or random wake-up after a shutdown whenever the BIOS WoL feature is enabled (as discussed in this thread for example). The following actions in the BIOS preferences can solve this issue with some motherboards:

Disable all references to xHCI in the USB settings (note this will also disable USB 3.0 at boot time)

Disable EuP 2013 if it is explicitly an option

Optionally enable wake-up on keyboard actions

Note: There are mixed opinions as to the value of #3 above and it may be motherboard dependent.

Battery draining problem

Some laptops have a battery draining problem after shutdown [1]. This might be caused by enabled WOL. To solve this problem, disable it by using ethtool as mentioned above.

If the link light on the network switch is enabled when the computer is turned off but wake on LAN is still not working, booting the system using the r8168 kernel module at least once and then switching back to the r8169 kernel module included with the kernel seems to fix it at least in the following configurations:

For the r8168 module you might need to set the s5wol=1module option to enable the wake on LAN functionality.

alx driver support

For some newer Atheros-based NICs (such as Atheros AR8161 and Killer E2500), WOL support has been disabled in the mainline alx module due to a bug causing unintentional wake-up (see this patch discussion). A patch can be applied (or installed as a dkms module) which both restores WOL support and fixes the underlying bug, as outlined in this thread.