Starting up another computer on a network itself is such a fascinating idea! For me, it literally feels like magic!
There are so many things involved. The computer which needs to be started (or woken up) has to have the capability, both at the hardware and the software level.
Also the computer doing the waking needs to send a magic packet!
When I initially heard this, I honestly thought this was a joke of some kind. A magic packet? Really?
In my case, I needed to wake up my home server whenever I resumed my PC from sleep or hibernation.
Since the computer is not too old, the motherboard already had support for Wake-on-LAN. On the software side, since my home server is Debian Linux, I had to invoke some incantations!
In the file
/etc/network/interfaces, which holds the entries of the network interfaces, we need to add the following line under the primary network entry:
So, effectively the complete file looks like this:
source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface allow-hotplug enp0s7 iface enp0s7 inet dhcp ethernet-wol g
Now, to test it from the desktop, which is running Windows, was another challenge. Because, when the server doesn’t wake up, you can’t quite figure out if the software that is being used to send the magic packet failed, or if the network had some issues, or if it was finally stuff on the server side (hardware / software) that might be breaking things.
Anyway, after many trials and tribulations, I finally found a software that works. WolCmd did the job perfectly as advertised. This is a command line program for which I had to create a batch file.
wolcmd [mac address] [ip address] 255.255.255.0 [port number]
In this command, the ip
address is of the computer we want to start remotely and the
mac address is that of the network interface of that system.
The default WOL port is
7, however the port which worked for me finally was
So, I could run the command. But the goal was to have this command executed automatically under two scenarios –
- When the computer starts
- When the computer resumes from sleep
The main point being – the magic packet should get sent without logging in.
To set this up, I used the Task Scheduler in Windows.
While creating the task, we should click on Create Task rather than ‘Create Basic Task’
This is because the ‘Create Task’ gives the customizations that will be required for this.
After giving the task name and description, we need to assign the triggers for this task.
In our case, the main trigger should be a task which is based on an event. Here, we choose ‘New Trigger’ and mention the trigger to be On an event. And then further down we select Custom to choose our custom event.
This is the main part. Click on New Event Filter, and select
By source. Then in the dropdown of Event sources, select
Power-Troubleshooter. And finally in the field which says , enter
The remaining fields are left as they are.
And finally in the action the fully qualified path to WolCmd (in quotes if there are space in the path), and the corresponding arguments.
I added another trigger for the same task for when the computer boots up. So, now the triggers window looks like this.
So, finally, I have a computer which fires the Wake command to my server every time it boots up or resumes from sleep, regardless of whether anybody is logged in or not.