Linux Wake-on-LAN setup for worldwide remote PC power on.

2 minute read

Wake-on-LAN can also work worldwide (over WAN Internet), in case your PC 10,000 km away gets turned off accidentally. To turn on a target PC from anywhere in the world, first you need to setup the target PC and router port forwarding (or have a VPN to the target subnet).

Setup

For simplicity/clarity we assume the following arbitrary parameters, which will be unique for your target Linux PC:

target interface target PC static LAN IP target public WAN IP public WoL port forward target MAC
eth0 192.168.1.100 1.2.3.4 10009 00:11:22:33:44:55

remote Linux PC

Modern Linux distros such as Ubuntu 18.04 have WakeOnLan configured in NetworkManager.

  1. Settings → Network and select the wired LAN interface you wish to use for WakeOnLan.
  2. under the “Ethernet” tab, seee that “Wake on Lan: Default” is checked. No Wake on LAN password is needed for most use caes.
  3. copy down this “Device” hexadecimal string, this is the MAC address, and you’ll use it to turn on the PC remotely. You can confirm you have the correct MAC address by typing in Terminal
    ip a
    
  4. Shutdown remote PC for testing. Have someone nearby it in case you can’t turn it back on.

setup control PC

On your laptop:

apt install wakeonlan

Usage

Wake PC on same LAN

on control PC, on the same LAN

wakeonlan 00:11:22:33:44:55

using the MAC address of the target PC of course.

If PC didn’t turn on, ensure BIOS/UEFI settings have Wake On Lan enabled. Try a discrete Intel Ethernet NIC, some motherboard NICs don’t work for Wake-on-LAN

setup worldwide Wake-on-LAN

To wake-on-LAN from anywhere in the world, using example parameters at top and after doing the procedure above, further do:

  1. Router: port forward 10009 to 192.168.1.100 port 9
  2. To use without Dynamic DNS service, have the PC auto-send email when the public IP address changes.
  3. From your control PC on a different network type in Terminal:
    wakeonlan -i 1.2.3.4 -p 10009 00:11:22:33:44:55
    

    and target PC should power on.

Notes

Legacy Linux remote PC setup

This procedure is for older Linux distros that don’t have WakeOnLan config in NetworkManager.

  1. install ethtool
    apt install ethtool
    
  2. add the following line to /etc/network/interfaces under the interface you want to control auto eth0
    up ethtool -s eth0 wol g
    
  3. edit /etc/init.d/halt, changing text near top to:
       NETDOWN=no
    

    instead of yes.

  4. edit/create /etc/default/tlp with line
    WOL_DISABLE=N
    
  5. note link/ether for eth0–this is MAC address
    ip a
    
  6. Reboot target PC, then shutdown target PC for testing

Leave a comment