Wake On Lan Command Line Basics: How to Turn On Computers RemotelyWake On LAN (WoL) is a powerful feature that allows you to wake a computer from a low power state remotely. This capability is especially useful for network administrators or home users wanting to manage multiple machines efficiently. Utilizing the command line to execute WoL commands offers flexibility and can be automated for consistent use. In this article, we’ll explore the fundamentals of Wake On LAN via the command line, including setup prerequisites, basic commands, and practical applications.
Understanding Wake On LAN
Wake On LAN uses network packets, specifically “magic packets,” that contain the MAC address of the target device. When a compatible machine receives this packet, it triggers a power-up sequence. The following components are essential for WoL to function:
- Motherboard Support: Ensure that your motherboard’s BIOS or UEFI supports WoL and that the setting is enabled.
- Network Interface Card (NIC): The NIC must also support WoL and be configured correctly in the operating system.
- Power Settings: The target computer must not be completely powered down; it should be in a standby or sleep state.
- Network Configuration: The machine must be connected to the network and reachable via its MAC address.
Prerequisites for Wake On LAN
Before you can effectively use the Wake On LAN command line utility, ensure the following:
1. BIOS/UEFI Configuration
- Enter the BIOS/UEFI settings during boot and navigate to power management settings.
- Look for an option labeled “Wake On LAN” or “Power On by PCI Device” and enable it.
2. Operating System Configuration
- On Windows, go to Device Manager, expand Network adapters, right-click on your NIC, select Properties, then navigate to the Power Management tab.
- Ensure that “Allow this device to wake the computer” is checked.
3. Necessary Tools
- On Windows, you can use built-in command line tools or third-party utilities.
- On Linux,
etherwakeorwakeonlanare popular command-line tools.
How to Use Wake On LAN Command Line
After ensuring that your systems are configured properly, you can begin using WoL via the command line. Below are examples for both Windows and Linux platforms.
For Windows
- Using PowerShell
Windows PowerShell is a powerful scripting environment that can be used to send WoL packets. To do this, you’ll need to create a simple function:
function Send-WOL { param ( [string]$macAddress, [string]$broadcastAddress = "255.255.255.255", [int]$port = 9 ) # Convert MAC address to byte array $macBytes = ($macAddress -split '[:-]') | ForEach-Object { [Convert]::ToByte($_, 16) } $macBytes = ,0xFF + ,$macBytes * 16 $packet = [byte[]]::new(102) [Array]::Copy($macBytes, $packet, $macBytes.Length) $udpClient = New-Object System.Net.Sockets.UdpClient $udpClient.Send($packet, $packet.Length, $broadcastAddress, $port) $udpClient.Close() }
To wake a device, run the function with the target MAC address:
Send-WOL -macAddress "00-11-22-33-44-55"
- Using Third-Party Tools
If scripting isn’t your preference, you can download tools like Depicus or WOL Command Line. These utilities offer simpler commands to send WoL packets.
For Linux
- Using
wakeonlanCommand
If you don’t havewakeonlaninstalled, you can generally install it using your package manager. Here’s how to install it on various distributions:
sudo apt install wakeonlan # For Debian/Ubuntu sudo yum install wakeonlan # For CentOS/RHEL sudo dnf install wakeonlan # For Fedora
Once installed, you can wake a machine with:
wakeonlan 00:11:22:33:44:55
- Using
etherwakeCommand
Alternatively, you can useetherwake. Install it similarly and use:
etherwake 00:11:22:33:44:55
Common Issues and Troubleshooting
Firewall Settings: Ensure that your firewall settings on both the sending and receiving devices allow WoL packets. Often, UDP traffic on port 9 must be open.
Network Configuration: Verify the network configuration
Leave a Reply