Prerequisites for Wake-on-LAN (WoL):

  1. Motherboard & BIOS Support: Enable WoL in BIOS/UEFI settings.
  2. Network Interface Card (NIC) Support: NIC must support WoL; enable it in device properties.
  3. Ethernet Connection: WoL typically requires a wired Ethernet connection.
  4. Power Supply: System should provide standby power (S5 state) to the NIC.
  5. Network Configuration: Correct MAC address, subnet, and port settings for the Wake-on-LAN packet.
  6. Software: Tool to send the “magic packet” (e.g., Depicus, WakeMeOnLan).

Ensure proper configuration on the OS (e.g., Windows, Linux).

  1. Enable WoL on Target Device:
    • Access BIOS or OS settings of the target device.
    • Enable “Wake on LAN” (WoL).
  2. Install Required Package on OpenWRT:
    opkg update
    opkg install etherwake
    
  3. Send WoL Packet from OpenWRT:
    etherwake -b <MAC_ADDRESS>
    

    Replace <MAC_ADDRESS> with the target device’s MAC address.

  4. Automate WoL Using OpenWRT Web UI (Optional):
    • Go to System > Startup.
    • Add a new script to send WoL command on startup. Example:
      /usr/bin/etherwake -b <MAC_ADDRESS>
      
  5. Ensure Network Setup:
    • Target device must be connected to the same subnet.
    • Proper forwarding/routing if WoL is sent across subnets.
  6. Alternative: Web Interface WoL Plugin
    • Install luci-app-wol:
      opkg install luci-app-wol
      
    • Access via Services > Wake on LAN on the OpenWRT web UI.

To execute the etherwake command via SSH, you can set up an alias or use the ProxyCommand option in the .ssh/config file. Here’s how:

  1. Edit .ssh/config:
    vim ~/.ssh/config
    
  2. Add the Following Configuration:
    Host wol-alias
        HostName <OpenWRT_IP>
        User <OpenWRT_Username>
        RemoteCommand /usr/bin/etherwake -b <MAC_ADDRESS>
        ExitOnForwardFailure yes
    
  3. Usage:
    ssh wol-alias
    

Explanation:

  • Host wol-alias: Create a custom alias (wol-alias) for the command.
  • HostName: IP address of your OpenWRT device.
  • User: Username to log in to OpenWRT.
  • RemoteCommand: Executes the etherwake command when you SSH into wol-alias.
  • ExitOnForwardFailure: Ensures the session exits after the command runs.

Note: Replace <OpenWRT_IP>, <OpenWRT_Username>, and <MAC_ADDRESS> with actual values.