How to Enable Wake-on-LAN in Ubuntu | #linux | #linuxsecurity

We all feel the desire to automate everything. Our cars, houses and especially our computers. Wake-on-LAN is the perfect way to automate turning your PC on.

While this guide will focus on how to enable Wake-on-LAN in Ubuntu, you can apply it to Linux distros, and you can even find the feature in Windows.

What Is Wake-on-LAN

Wake-on-LAN or WOL is a feature that allows you to turn on your PC from another device via the network. It does this by sending a tiny “magic” packet of data from a host computer. The network driver of the receiver computer can receive this data and signal the device to power on.

How to Prepare Your Setup for Wake-on-LAN

For Wake-on-LAN to work, your ethernet card needs to support the feature. This feature has been standard for at least 10 years, so chances are high it will, but it is always good to double-check.

Your ethernet interface is the network card of your device. Every card has a unique name. You can find it with the following terminal command:

The name you’re looking out for is similar to “enp8s0.” This was the unique ID of the network card used in this tutorial.


Ethtool is an open-source application that allows you to change network driver settings. For wake-on-LAN, it will allow your PC to understand the data it’s receiving.

The command to install ethtool is:

The tool is also available on if you encounter issues installing from the terminal.

Next, you need to find out whether your network card supports wake on LAN.

sudo ethtool <Your interface name>

You’ll be given detailed information on your ethernet interface hardware. What we are looking for is this:

Supports Wake-on: g
Wake-on: g

The first line tells you whether your PC supports Wake-On-LAN. There might be other letters along with the g. For now, we only need the “g.”

The second line shows whether Wake-On-LAN is enabled. Don’t worry too much about that, as our next task will be to enable it.

Enable Wake-on-LAN

The command to enable Wake-on-LAN is as follows:

sudo ethtool --change <Your ethernet interface name> wol g

This will enable the service and allow your PC to be turned on by a network device. To power on the device using this feature, all you need to do is type the following in terminal, Windows PowerShell or command prompt.

wakeonlan -i <IP Address> <MAC Address>

Now, this will enable it to power on once via a magic packet. However, the service doesn’t turn on on start up and is disabled after the first time. Ideally, you want to be able to power it on every time.

Automating Wake-on-LAN

First, you need to find where ethtool is installed. This terminal command will do that.

Secondly, you need to create a file that enables the service on boot. You can do this in your favorite text editor and place the file in “/etc/systemd/system/”.

The contents of the file should be:

Description=Enable Wake On Lan
ExecStart = <Your filepath> --change <Your ethernet interface name> wol g

The vital bit in this section is the service and install parts. Oneshot is the default type parameter. It means that your service manager (systemd in Ubuntu) will execute the commands sequentially and once. Perfect, because you want to change your wake-on-LAN setting to go once.

The install section tells systemd that your WOL service should run on the first level. The concept of levels, grouping, and how the system manager works is another rabbit hole, but all you need to know for now is that it will start on boot.

An issue you may run into in this section is permissions. By default, Ubuntu will not allow you to add files to the systemd folder. You can change this using chmod. You need to have read and write permissions for this.

Final Steps

The final step is to restart daemon and enable the service. This will happen automatically if you restart your system, but it is quicker to do it in the terminal.

sudo systemctl daemon-reload
sudo systemctl enable wol.service

Systemctl controls systemd and daemons are essentially helper applications. What you’re doing here is restarting the supervisor so that detects the new file in the systemd folder.

You can check whether the service is running using:

Wireless Wake-on-LAN

Now, you can turn on your PC via LAN but what about wireless wake-on-LAN or woWLAN? As of this article, there is only a snap application (network-manager) that allows you to do this.

You can install this from the snap store or the terminal using this command.

sudo snap install network-manager
Wake On Lan Snap Store

Beware that this application is only rated 1 star in the store. During testing, the application ran as expected in the terminal. It also has full-length documentation by Canonical.

You can attempt to enable woWLAN using another network manager, but the default (networkd) has no method of enabling it.

You can enable wireless wake-on-LAN using this command:

sudo snap set network-manager wifi.wake-on-wlan=magic

If you’re on an open network or wary of security threats, you can set a password using:

sudo snap set network-manager wifi.wake-on-wlan-password=<Your password>

There are some advantages to using this method over ethtool. It’s quicker to install and allows wireless wake-on-LAN. It has kernel level access, so if the computer loses power, you can still use wake-on-LAN when power returns.

The issue is that Canonical only recommends it for Ubuntu core users. There is no specific reason for this, but it’s likely to keep the application contained and to prevent users from breaking their OS.

Frequently Asked Questions

Can I power down my PC using Wake-on-LAN?

You can only wake your PC up from standby or a power-off state. There are methods of doing this, they do not use wake-on-LAN.

Is it a security risk to enable Wake-on-LAN?

Only devices on the same network can power on your device using wake-on-LAN. Ubuntu also requires you to authenticate after powering on. As long as you avoid unsafe Wi-Fi networks, it is safe to enable wake-On-LAN.

After my device lost power, Wake-on-LAN no longer works. How can I fix this?

Ethtool does not persist when power is lost. Logging in again should re-enable the service. If you used the network-manager method, it will persist when you lost power.

Image credit: Technician team connect cable wire network to router by 123RF

Is this article useful?

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Original Source link

Leave a Reply

Your email address will not be published.

39 − = thirty four