How to Enable Wake-on-LAN in Ubuntu

We all like to automate things: cars, homes, and especially computers. Wake-on-LAN is the perfect way to automatically turn on your PC. While this guide focuses on enabling Wake-on-LAN in Ubuntu , you can apply it to any Linux distribution and you can even find the feature in Windows.

 

What is Wake-on-LAN?

Wake-on-LAN is a networking standard that allows you to turn on or wake up your computer using a network message. This message, called a Magic Packet, is sent from another device on the same local network or even over a wireless network.

The Magic Packet contains the MAC address of the target computer's network interface card (NIC), which uniquely identifies the hardware. When the NIC, which remains in a low-power state even when the computer is off, receives this packet, it signals the motherboard to power on the system.

 

Preparing to setup for Wake-on-LAN

Before you begin, make sure you meet the following basic requirements:

  1. Wired Ethernet connection (Wi-Fi WoL is limited and often unreliable)
  2. Compatible motherboard and network card (most modern ones support it)
  3. BIOS/UEFI settings that support WoL
  4. Administrative access to Ubuntu machine

Check hardware and BIOS settings

First, you need to make sure your hardware supports Wake-on-LAN. Most modern desktops and many laptops do, but it's worth double-checking.

Restart your computer and press the appropriate key to enter BIOS/UEFI (usually F2, F10, Del, or Esc – watch the screen as it boots). Look for options like Wake-on-LAN, Power on by PCI-E, PCI Power Up, or Allow PCI Wake-Up Event. The exact names vary by manufacturer. Set the option to Enabled .

You may also want to disable features called ErP Ready or Deep Sleep, as these power-saving modes can completely cut off power to the network card, preventing it from receiving magic packets. Some laptops also require settings like Always On USB to keep the network card powered when shut down or hibernating.

 

Check if the network card supports Wake-on-LAN

For Wake-on-LAN to work, your Ethernet card needs to support it. This has been standard for at least 10 years, so there's a good chance your card does, but you should double check.

The Ethernet Interface is the device's network card. Each card has a unique name which is found with the following terminal command:

ip a

The name you are looking for is similar to enp8s0. This is the unique ID of the network card used in this guide.

How to Enable Wake-on-LAN in Ubuntu Picture 1

 

Ethtool is an open source application that allows you to change network driver settings. For Wake-on-LAN, it allows the PC to understand the data it is receiving.

The command to install ethtool is:

sudo apt install ethtool

Next, find out if your network card supports Wake on LAN.

sudo ethtool 

You will be provided with detailed information about your Ethernet interface hardware. We are looking for:

Supports Wake-on: g Wake-on: g

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

The second line indicates whether Wake-On-LAN is enabled or not. Don't worry too much about that, because our next task will be to enable it.

Enable Wake-on-LAN temporarily

Enabling Wake-on-LAN will require the NIC to wake up the system only when a specific magic packet is received.

To enable Wake-on-LAN temporarily, run:

sudo ethtool -s  wol g 

This enables WoL until the next reboot. To verify that it works, run:

sudo ethtool 

If you see Wake-on: g, it means that WoL was successfully enabled. However, the settings applied by ethtool are not persistent and will be lost after a reboot.

Enable Wake-on-LAN permanently

For Wake-on-LAN to be truly useful, it needs to be enabled even after your Ubuntu machine reboots. We can do this by creating a systemd service that automatically runs the ethtool command at boot. This is a common and robust way to ensure that settings persist in modern Linux distributions.

 

First, create a new systemd service file. We'll use nano, a simple text editor, but you can use Vi or any other editor you like:

sudo nano /etc/systemd/system/wol.service

If you are not sure where ethtool is installed, run:

which ethtool

Paste the following content into the service file:

[Unit] Description=Enable Wake On Lan [Service] Type=oneshot ExecStart = --change wol g [Install] WantedBy=basic.target

Once you have pasted the content and made your substitutions, save the file and exit nano. To do this, press Ctrl + X , then Y to confirm the save, and finally Enter to confirm the file name.

Finally, we need to tell systemd to enable this new service so that it runs at boot. This creates a symbolic link that enables the service:

sudo systemctl enable wakeonlan.service

Once enabled, you can optionally start the service immediately without rebooting with the following command:

sudo systemctl start wakeonlan.service

Now your Ubuntu Server or Desktop will always have Wake-on-LAN enabled during reboots.

Using the advanced network connection editor

For most Ubuntu desktop users, the graphical network connections editor provides the simplest way to enable Wake-on-LAN.

Just open advanced network connection settings from the app menu.

How to Enable Wake-on-LAN in Ubuntu Picture 2

In the Network panel, you will see your wired connection listed. Click the gear icon and open the connection settings.

 

How to Enable Wake-on-LAN in Ubuntu Picture 3

In the Ethernet settings tab, look for Wake on LAN. Check the box labeled Magic or MagicPacket and press Apply .

How to Enable Wake-on-LAN in Ubuntu Picture 4

That's it! You have successfully enabled Wake-on-LAN. To verify, run:

sudo ethtool enp0s3

Look for Wake-on: g in the output.

5 ★ | 1 Vote

May be interested