To wake another computer on your network using Wake-on-LAN (WOL) from your Raspberry Pi, follow these steps:


1. Ensure the Target Computer Supports WOL

  • Make sure the target computer’s BIOS/UEFI settings enable Wake-on-LAN.
  • Enable WOL in the operating system settings (e.g., for Windows, it’s under the Network Adapter properties -> Advanced or Power Management).

2. Find the MAC Address of the Target Computer

On the target computer, find the MAC address of the network interface:

  • Windows: Run ipconfig /all in Command Prompt and look for the “Physical Address” under the correct network adapter.
  • Linux: Run ip link or ifconfig and find the MAC address (e.g., eth0 or wlan0).

Example MAC address: 00:1A:2B:3C:4D:5E


3. Install WOL Tool on Raspberry Pi

SSH into your Raspberry Pi or use its terminal and install the wakeonlan tool:

sudo apt update
sudo apt install wakeonlan

4. Send the Wake-On-LAN Magic Packet

Use the wakeonlan command to wake the target computer:

wakeonlan 00:1A:2B:3C:4D:5E

Replace 00:1A:2B:3C:4D:5E with the MAC address of the target computer.


5. Optional: Automate the Process

You can create a simple script on your Raspberry Pi to wake the computer with one command.

a. Create a Script

Create a script file:

nano wake_pc.sh

Add the following content:

#!/bin/bash
wakeonlan 00:1A:2B:3C:4D:5E

Save and exit the file (Ctrl + O, then Enter, and Ctrl + X).

b. Make the Script Executable

chmod +x wake_pc.sh

c. Run the Script

Execute the script to wake the computer:

./wake_pc.sh

6. Troubleshooting

  • Ensure the Raspberry Pi and the target computer are on the same network.
  • Verify the target computer’s network card supports WOL in a shutdown state.
  • Check if any firewall is blocking the magic packet.
  • Use a tool like Wireshark on another device to confirm the magic packet is being sent.

No, Wake-on-LAN typically won’t work over the internet without additional configuration, because the magic packet is a broadcast packet sent to the local network, and most routers do not forward broadcast packets across networks.

However, there are ways to make it work:


1. Use Port Forwarding

You can configure your router to forward WOL packets to your Raspberry Pi’s local network. Here’s how:

a. Configure Your Router

  • Log in to your router’s configuration page.
  • Set up port forwarding for UDP traffic (commonly on port 9 or 7) to the broadcast address of your network or directly to the Raspberry Pi.

For example:

  • Internal IP: 192.168.1.255 (broadcast address)
  • Port: 9 (or 7)

Some routers allow you to directly forward to the Raspberry Pi’s IP instead of the broadcast address. In such cases:

  • Internal IP: 192.168.1.<Raspberry_Pi_IP>
  • Port: 9

b. Send the Magic Packet from Your Remote Location

On your remote device, use a WOL tool or send the magic packet targeting your router’s public IP and the forwarded port.

Example command:

wakeonlan -i <Router_Public_IP> <MAC_Address>

Replace <Router_Public_IP> with your router’s public IP address and <MAC_Address> with the target computer’s MAC address.


2. Use Raspberry Pi as a WOL Proxy

You can SSH into your Raspberry Pi (already on the same local network as the target computer) and send the wakeonlan command from there. This avoids needing router configurations.

Steps:

  1. SSH into the Raspberry Pi over the internet:
    ssh pi@<Raspberry_Pi_Public_IP>
    
  2. Run the wakeonlan command from the Raspberry Pi:
    wakeonlan <Target_Computer_MAC_Address>
    

3. Set Up a WOL Web Service

You can run a simple web server on your Raspberry Pi to trigger WOL. Here’s an outline:

  • Install a lightweight web server like Flask.
  • Write a Python script to send the magic packet when triggered via a browser.
  • Access the web interface from anywhere to wake your computer.

Let me know if you’re interested in this approach, and I can guide you in detail!


Summary

If you’re connected to the Raspberry Pi via SSH, running wakeonlan on the Raspberry Pi will work because the Raspberry Pi is on the same local network as the target computer. Over the internet, you’ll need to configure port forwarding or use the Raspberry Pi as a proxy for the WOL request.