Wake On Lan Mesh
The Wake On Lan Mesh (WOLMesh from here on in) is designed to help with managing the power of Remote Computers via Wake on Lan. With all the mayhem of COVID-19, many administrators find themselves supporting far more users remotely than ever before. Some have elected to allow their users to logon via Citrix CVAD / VMware Horizon / Microsoft RDP technologies that allow remote pc access.
This use case really falls down when the user accidentally or intentionally shutdown their PC. Or perhaps the PC is powered down due to power policies. Wake on Lan can help here if you happen to be on the same subnet, are able to broadcast and know the mac address of the PC.
WOLMesh aims to help people who have limitations around Wake on Lan today by providing a Web Portal and REST API to allow administrators to view power status of remote machines and power them on via other machines on the same subnet should they need to.
WOLMesh can also be configured to keep devices (registered, or manual) online during certain times. E.G. if you sent an online time between 9 AM and 5 PM, if a device goes offline, WOLMesh will attempt to wake it up. Further, if devices are offline and the online time begins (say 9 AM) WOLMesh will attempt to wake all the devices and keep them awake.
Registered Devices / Relays:
Devices and Relays:
The target machines for WOLMesh can be deployed in three ways:
- Registered Machines
- Manual Machines
Registered Machines are machines running a WOLMesh agent. This agent maintains constant communication with the WOLMesh server, to report current user, and it's online state. The agent is extremely thin and allows the WOLMesh server to relay Wake on Lan packets to powered off machines on the same subnet.
Relays are like registered machines, they maintain a constant connection to the WOLMesh server but are designed strictly for non windows playforms such as MacOS or Linux. This usecase is really for leveraging inexpensive devices such as Raspberry Pi's to wake up subnets of devices.
Manual machines are added to the WOLMesh server manually (via DNS Name, Mac Address and the broadcast address) of the network they reside. Manual devices do not have a dedicated connection to the WOLMesh server, as such their online state is determined by ICMP.
In the case of manual machines, every 1 minute, the devices DNS name is looked up, the ip address is updated (if neccessary) and a 2 second ttl ICMP is sent to the device. Should the device fail to respond, it's considered down.
How machines are woken:
When a wake request is sent for a device, from the Web App or REST API, WOLMesh check's its active connections, if devices or relays are found on the same subnet, subnet local broadcasts are sent from up to 3 devices (configurable) to the mac address of the machine requested.
If the server is on the same subnet as the target device, the server will attempt to also send a wake up.
If no devices are online in the target subnet, and the server is not on the same subnet. It will attempt to perform a directed broadcast to the subnet. This will most likely be blocked by most networks, but it never hurts to try ;)
The WOLMesh Server is an ASP.Net Core Web API written in .Net Core 3.1. This service provides the following services:
- Web API
- Web Portal (Angular)
- SignalR Realtime Communication.
The WOLMesh service needs to be run on a central server, or machine that will not be powered down and the agents must be pointed at it. Once the process is started, it accepts connections via SignalR as devices register themselves with the server. Devices are stored in the local.db (sqlite) database.
From the web portal, you can view the registered devices and their power state. You can also power devices on from the console.
From the REST API, you can list and power manage devices in bulk or in an automated fashion.
Requires .Net Framework 4.7.2
The WOLMesh Agent needs to be installed on all devices you wish to manage with WOLMesh. Once installed, you must configure the agent to communicate with the server via a SignalR websocket. Once connected, the agent monitors it's network connection and state and sends it to the server.
Once connected, the device can be leveraged to wake up other devices on the same subnet.
The WOLMesh Daemon is designed to be used for relaying Wake On Lan Messages from the server, to the Daemon, for machines on the same network as the Daemon.
Once installed, the nodeconfig.json file must be updated to point to the server, once the process begins, this Daemon will be used as a relay to wake up other devices on the same subnet.
How to install:
In the publish folder above, you'll find both the agent and server zip file:
Download the above web service zip file and extract it on a machine (tested on windows 10 / Server 2016). Once extracted, run the following executable with administrator priveledges to start the web service:
Once started, the webservice will begin listening on the default port of 7443. A self signed certificate will be created on demand. you can then browse to https://server:7443 to begin using the webapp.
Note: Please ensure to run the process as administrator to ensure it can bind to the local ip address, for remote access.
Run as service:
If you would prefer to run this as a service: here's an example command:
New-Service -Name "WOLMeshWebAPI" -DisplayName "Wake on Lan Mesh Web API" -BinaryPathName C:\wolmesh\WOLMeshWebAPI.exe -Description "This Web Application will wake Remote PC's leveraging Wake On Lan" -StartupType Automatic
- On a target machine, install the agent msi file.
- Download the windows-nodeconfig.json file and modify the server address
- Rename the file to nodeconfig.json and place the file in the installation folder.
- Start the Wake On Lan Mesh Agent service.
- Your device should now appear in the console.
Linux / Raspberry Pi:
- Download the correct version for your build (linux x64, ARM for raspberry pi) above.
- Extract the contents to /usr/bin/wolmeshclient or another directory in the linux file system.
- Download the daemon-nodeconfig.json file, modify the serveraddress field, rename it to nodeconfig.json and store it in the same directory as the installation.
- Make the file executable:
sudo chmod +x /usr/bin/wolmeshclient/WOLMeshClientDaemon
- once it's executable, run:
- The Device should now appear in the console.
Running as a Daemon:
- Run the following command to create the service reference:
sudo nano /etc/systemd/system/WOLMeshDaemon.service
- Add the following text to the config file:
[Unit] Description=WOL Mesh Daemon Service After=network.target StartLimitIntervalSec=0 [Service] Type=simple Restart=always RestartSec=1 ExecStart=/usr/bin/wolmeshclient/WOLMeshClientDaemon [Install] WantedBy=multi-user.target
3: reload the daemon, enable the service and start it:
sudo systemctl daemon-reload sudo systemctl enable WOLMeshDaemon sudo systemctl start WOLMeshDaemon
- Machines need to be configured to enable Wake on Lan (bios and driver settings). This guide covers it well: https://www.partitionwizard.com/partitionmanager/enable-wake-on-lan.html
- Added support for Manual Devices (without an agent).
- Added support for Linux (x64)
- Added support for Mac OS
- Added support for Arm (raspberry pi)
- Added the ability to run web service as service.
- Added the ability to run the agent / client on linux / arm as a Daemon.
- Changed the core logic to allow the server to send the Wake On Lan message if on the same subnet.
- Changed the logic to try a directed broadcast if all else fails.
- Added Swagger and Swagger UI. (/swagger/index.html)
- Added the ability to change the default ssl certificate for the web service.
This is my "I gotta do these things next" list. I welcome all suggestions.
- Implement Authentication.
Allow server to use another ssl cert. Allow wake up of unknown devices. Networks view.
- Online devices view.
Run as Service for web service. Stupid .Net Core 3.0 changed everything. Test agent for Linux / Raspberry Pi. Add Swagger and test REST API.
- Make the agent a little easier to deploy.