The Ultimate Guide on How to Enable Wake-On-LAN in Ubuntu
Enabling Wake-on-LAN in Ubuntu
Wake-on-LAN (WOL) is a feature that allows you to turn on your computer remotely by sending a specially formatted packet to the network interface. This can be particularly useful for managing servers or workstations that are not easily accessible. Here’s a step-by-step guide on how to enable Wake-on-LAN in Ubuntu.
Preparing Your Setup
Before you start, ensure that your Ethernet card supports Wake-on-LAN. This feature has been standard for many years, but it's always good to double-check.
-
Check Ethernet Interface Name:
Use theip a
command to find the name of your Ethernet interface. The name will be something likeenp8s0
.ip a
-
Check Wake-on-LAN Support:
Useethtool
to check if your network card supports Wake-on-LAN.sudo ethtool <Your interface name> | grep Wake
Look for
Supports Wake-on: g
andWake-on: d
. Theg
indicates that Wake-on-LAN is supported, andd
means it is currently disabled.
Installing Required Software
-
Update Package List and Upgrade:
Ensure your package list is up to date and upgrade any out-of-date packages.sudo apt update sudo apt upgrade -y
-
Install ethtool:
ethtool
is the tool you will use to enable Wake-on-LAN. Install it if it's not already installed.sudo apt install ethtool
Enabling Wake-on-LAN
-
Enable Wake-on-LAN:
Useethtool
to enable Wake-on-LAN on your Ethernet interface.sudo ethtool --change <Your ethernet interface name> wol g
Replace
<Your ethernet interface name>
with the name of your Ethernet interface, such asenp8s0
.
Ensuring Wake-on-LAN Is Enabled at Startup
To ensure Wake-on-LAN remains enabled between reboots, you need to create a systemd service.
-
Create the Service File:
Create a new file in the systemd directory.sudo nano /lib/systemd/system/wakeonlan.service
-
Add Service Configuration:
Add the following lines to the file, replacing<DEVICE NAME>
with your Ethernet interface name.[Unit] Description=Enable Wake On Lan After=network-online.target [Service] Type=oneshot ExecStart=/usr/sbin/ethtool -s <DEVICE NAME> wol g [Install] WantedBy=network-online.target
-
Save and Exit:
Save the file by pressing CTRL + X
, then Y
, and finally ENTER
.
-
Enable the Service:
Enable the service to run at startup.sudo systemctl enable wakeonlan.service
-
Reload Systemd Daemon:
Reload the systemd daemon to apply the changes.sudo systemctl daemon-reload
-
Check Service Status:
Verify that the service is enabled and running correctly.
systemctl status wakeonlan
Verifying Wake-on-LAN
-
Shut Down and Verify:
Shut down your computer, wait for 10 seconds, and then restart to ensure the physical network device isn’t retaining prior settings. After rebooting, check that Wake-on-LAN is enabled.sudo ethtool <Your interface name> | grep Wake
It should show
Wake-on: g
.
Sending the Magic Packet
To wake up your computer remotely, you need to send a magic packet to its MAC address.
-
Get Your MAC Address:
Find the MAC address of your Ethernet interface.ip a
-
Install wakeonlan:
If you haven't already, install thewakeonlan
package.sudo apt install wakeonlan
-
Send the Magic Packet:
Use the wakeonlan
command to send the magic packet.
wakeonlan -i <IP Address> <MAC Address>
Replace <IP Address>
with the broadcast IP address (usually 255.255.255.255
) and <MAC Address>
with the MAC address of your computer.
BIOS Settings
Ensure that Wake-on-LAN is also enabled in your BIOS settings. This is often found under a Power submenu. Reboot your computer and enter the BIOS configuration (usually by pressing F2
, DEL
, or F12
) to check and enable this setting if necessary.
By following these steps, you will have successfully enabled Wake-on-LAN on your Ubuntu system, allowing you to remotely wake up your computer whenever needed.