YuGabe.WakeOnLan 1.0.0

.NET 6.0
dotnet tool install --global YuGabe.WakeOnLan --version 1.0.0
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local YuGabe.WakeOnLan --version 1.0.0
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=YuGabe.WakeOnLan&version=1.0.0
nuke :add-package YuGabe.WakeOnLan --version 1.0.0

WakeOnLan / "wol"

A no-nonsense, simple Wake-on-LAN implementation, that can be invoked via the command 'wol'.

Usage

wol <target MAC address>

<target MAC address> is a string containing exactly 12 hexadecimal characters (0-9, A-F, case insensitive) and any additional non-whitespace delimiters (':', '-', '_' etc.).

Examples

wol 12:34:56:78:9A:BC

wol 12345_6789!aBCdE*f

wol 123456789ABCDEF

Remarks

For Wake-on-LAN to work, make sure that:

  • the current machine and the target machine are on the same local subnet,
  • the UDP port 12287 or UDP broadcasting is not blocked any firewalls on the network (including Windows Firewall and routers/switches),
  • Wake-on-LAN is supported by the target machine, as not all motherboards/Ethernet cards support it, and some only when the computer is sleeping,
  • Wake-on-LAN is enabled by the target machine (usually in UEFI/BIOS).

Notes regarding the source

The source code is essentially the following two lines of code:

using var client = new System.Net.Sockets.UdpClient("255.255.255.255", 12287) { EnableBroadcast = true };
await client.SendAsync(Enumerable.Repeat<byte>(255, 6).Concat(Enumerable.Repeat(Enumerable.Range(0, 6).Select(i => Convert.ToByte(mac.Substring(i * 2, 2), 16)), 16).SelectMany(b => b)).ToArray(), 102);

In plain words, the 6 bytes FF FF FF FF FF FF are followed by the target MAC address 16 times, and sent to the UDP broadcast address on port 12287.

This is preceded by validation, and the documentation if wrong input is detected.

Product Versions
.NET net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
1.0.0 79 5/2/2022