Wake on LAN: Linux, Windows and Routers

Wake-on-LAN (WoL) is a feature that lets you turn on computers remotely. This can be done by sending a special network message called a "magic packet." This packet contains the MAC address of the target computer's network card.

When the network card receives this packet, it triggers the computer to power on. WoL is perfect for scenarios where you need to access files, run updates, or manage your network without being physically present. This guide will show you how to set up and use WoL on Linux, Windows, and various network devices.

Configuring your computer for WoL is essential for several reasons. Firstly, it allows you to turn on your computer remotely, enabling access to files and applications without physical presence. Secondly, keeping your computer off and turning it on only when needed reduces energy consumption.

1. Network Topology

Figure 1 depicts a network environment with two computers, central server and a router. A "magic packet",  is emitted from the server or the gateway towards specific computers. These computers receive the magic packet through their network interfaces, causing them to power on remotely."

Figure 1 - Sending Wake-on-LAN packets from Server and Router to PC1 and PC2

2. Configuring Host for Wake-on-LAN Support

To enable WoL, you need to configure computer's BIOS/UEFI settings. Proper configuration ensures your PC can receive and respond to the magic packet.

  • Enter BIOS/UEFI Setup: Restart your computer and press the key (usually F2, F10, F12, or Delete) to enter the BIOS/UEFI setup.
  • Navigate to Power Management Settings: Look for settings related to power management or advanced power management.
  • Enable Wake-on-LAN: Find the Wake-on-LAN setting and enable it. This might be listed under different names such as "Wake on LAN," "WOL," or "Power on by LAN."
  • Save and Exit: Save your changes and exit the BIOS/UEFI setup.

Dell OptiPlex Setup for Wake on LAN:

  • Enter Setup: Press F12 during boot to enter the setup.
  • Navigate to Power Management: Go to Settings -> Power Management -> Wake on LAN/WLAN and select "LAN only."

3. Linux

Linux systems support Wake-on-LAN (WoL), which simplifies remote management of servers and desktops. This section covers how to install and use the various WoL tools in Debian Linux.

3.1 Perl

Debian 11 and other Debian-based distributions provide a Perl script for WoL in their repositories. This script simplifies sending WoL packets.

The wakeonlan utility is a simple Perl script that can be installed directly from the repository, making the setup process straightforward. This script is stored in /usr/bin directory.

$ sudo apt install wakeonlan

Use the wakeonlan command followed by the MAC addresses of the computers you want to wake up.

$ /usr/bin/wakeonlan 14:1f:14:18:11:16 18:10:16:17:19:18

3.2 Python

Python offers another way to send Wake-on-LAN packets using the wakeonlan package. Python's flexibility and widespread use make it a good choice for scripting tasks.

The pip3 command is a package installer for Python. It is used to install and manage software packages written in Python. Here, it installs the wakeonlan package, which contains functions to send WoL packets.

$ sudo pip3 install wakeonlan

Utilize wakeonlan module to send magic packets to multiple computers:

$ python3 /usr/local/bin/wakeonlan 14:1f:14:18:11:16 18:10:16:17:19:18

3.3 Etherwake

Etherwake is a command-line utility specifically designed to send Wake-on-LAN packets. It requires specifying the network interface (-i) through which the magic packet should be sent.

Download and install etherwake from Debian repository:

$ sudo apt install etherwake

Replace eth0 with your actual network interface name (ifconfig or ip addr to find it) and specify MAC addresses:

$ sudo etherwake -i eth0 18:10:16:17:19:18
$ sudo etherwake -i eth0 14:1f:14:18:11:16

Use a loop to send WoL packets to multiple MAC addresses efficiently.

$ for mac in "18:10:16:17:19:18" "14:1f:14:18:11:16"; do sudo etherwake -i eth0 $mac; done

4. Windows

Windows systems support Wake-on-LAN (WoL), enhancing remote server and desktop management. This section covers the installation and usage of WoL tools on Windows to wake computers on the network

4.1 Wake on LAN with PowerShell

For Windows users, PowerShell provides a script-based approach to send WoL packets. Obtain the script from GitHub and configure PowerShell for execution.

Copy the script Invoke-WakeOnLan.ps1 to the computer With Windows. Navigate to the directory when script has been copied, e.g.:

> cd /Users/admin/Desktop

Press Win-R key combination and type powershell command. Press CTRL-Shift and Enter to start powershell as administrator. Check execution policy for Windows computer with the command:

> Get-ExecutionPolicy

If it's "Restricted," change it to "RemoteSigned" with Set-ExecutionPolicy RemoteSigned. This will allow running unsigned scripts that you write on your local computer and signed scripts from Internet.

> Set-ExecutionPolicy RemoteSigned

Execution the script as following:

> .\Invoke-WakeOnLan.ps1 -MacAddress 14:1f:14:18:11:16, 18:10:16:17:19:18

4.2 Wake on LAN with GUI Utility

In addition to command-line tools, there are GUI-based applications for Wake-on-LAN on Windows. One of them is  "Wake on Lan" tool from The Aquila Technology. Download the WakeOnLAN app from GitHub and install it on your Windows computer.

Press Ctrl+N to add a new host. Navigate to Wake Up tab. Enter the MAC address of the target computer. If the IP address is unknown, you can enter 255.255.255.255. See Figure 2 for reference on adding a new host to the host list.

Figure 2 - Adding New Host to Management

After adding both hosts, initiate the wake-up process. Select both hosts with your mouse to highlight them in blue. Click the "Wake Up" option as shown in Figure 3.

Figure 3 - Powering On Hosts in LAN Network

5. Network Devices

Network devices often offer centralized Wake-on-LAN (WoL) capabilities similar to those found in desktop Linux systems. This section explores how to leverage these built-in features to remotely manage and wake computers on your network.

3.1 Mikrotik

MikroTik routers support Wake-on-LAN functionality through the tool/wol command in the RouterOS CLI. By default, the magic packet is sent as an IP broadcast out the default gateway interface. However, you can specify a particular interface if needed.

> tool/ wol mac=14:1F:14:18:11:16 interface=bridge
> tool/ wol 18:10:16:17:19:18 interface=bridge

To efficiently send WoL packets to multiple devices, you can use a foreach loop:

 > :foreach mac in={"14:1F:14:18:11:16"; "18:10:16:17:19:18"} do={/tool wol mac=$mac interface=bridge}

3.2 VyOS

VyOS, a Linux-based network operating system, also supports Wake-on-LAN using the wake-on-lan command. You can specify the interface (interface) and the host's MAC address (host) to wake up the target device.

$ wake-on-lan interface eth0 host 14:1f:14:18:11:16
$ wake-on-lan interface eth0 host 18:10:16:17:19:18

For batch wake-up of multiple devices, use a loop:

$ for mac in "14:1f:14:18:11:16" "18:10:16:17:19:18"; do wake-on-lan interface eth0 host $mac; done

These commands allow VyOS users to wake up computers across their network infrastructure efficiently and manage devices remotely.

Conclusion

Wake-on-LAN is a powerful tool for remotely managing and maintaining systems. Whether you are using Linux, Windows, or network devices, the ability to wake up computers remotely can save time and decrease power consumption. By following the steps outlined in this guide, you can easily set up and use WoL across different platforms.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.