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.

  1. Check Ethernet Interface Name:
    Use the ip a command to find the name of your Ethernet interface. The name will be something like enp8s0.

    ip a
    
  2. Check Wake-on-LAN Support:
    Use ethtool to check if your network card supports Wake-on-LAN.

    sudo ethtool <Your interface name> | grep Wake
    

    Look for Supports Wake-on: g and Wake-on: d. The g indicates that Wake-on-LAN is supported, and d means it is currently disabled.

Installing Required Software

  1. 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
    
  2. 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

  1. Enable Wake-on-LAN:
    Use ethtool 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 as enp8s0.

Ensuring Wake-on-LAN Is Enabled at Startup

To ensure Wake-on-LAN remains enabled between reboots, you need to create a systemd service.

  1. Create the Service File:
    Create a new file in the systemd directory.

    sudo nano /lib/systemd/system/wakeonlan.service
    
  2. 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
    
  3. Save and Exit:

Save the file by pressing CTRL + X, then Y, and finally ENTER.

  1. Enable the Service:
    Enable the service to run at startup.

    sudo systemctl enable wakeonlan.service
    
  2. Reload Systemd Daemon:
    Reload the systemd daemon to apply the changes.

    sudo systemctl daemon-reload
    
  3. Check Service Status:

Verify that the service is enabled and running correctly.

systemctl status wakeonlan

Verifying Wake-on-LAN

  1. 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.

  1. Get Your MAC Address:
    Find the MAC address of your Ethernet interface.

    ip a
    
  2. Install wakeonlan:
    If you haven't already, install the wakeonlan package.

    sudo apt install wakeonlan
    
  3. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *