On target (PC to be remotely controlled)
sudo apt install ethtool
backup your /etc/network/interfaces file:
sudo cp /etc/network/interfaces /etc/network/interfaces.backup
Edit network config
sudo nano /etc/network/interfaces
You should see a segment that looks like the following. If not, try adding it. Note, if this goofs up, you may not have network access for your machine until you copy the .backup file you made in the previous step!
auto eth0 iface eth0 inet dhcp up ethtool -s eth0 wol g
sudo nano /etc/init.d/halt
change the text near the top of the file to say
instead of yes.
ifconfigand note HWaddr for eth0–this is MAC address
- Reboot remote PC, then shutdown remote PC
setup controlling PC
sudo apt install wakeonlan
Wakeup remote PC on same LAN
on your control PC (while on the same LAN)
WHERE HWaddr is the MAC address of the remote PC
E.g. if HWaddr of remote PC is 00:11:22:33:44:55 then type on the control PC (on the same LAN):
You will need to have Port Forwarding capability to your PC from your router, otherwise, you would have to be on the same subnet–perhaps via VPN.
Let’s assume your remote PC is assigned the DHCP reserved address 192.168.1.100 by your router. Let’s also assume you forwarded say port 1234 to port 22 for SSH/RDP control.
setup your router to forward a second port
say 4321 for UDP packets to port 9 (port 9 is Wake on Lan magic packet port), to 22.214.171.124.
Finally, you need to know the WAN (world-facing) address of your router–this needs to be relatively fixed, or use one of the “DynDNS” type services. These days it seems a lot of internet providers keep the same IP addresses for their customers for long periods of time (years). Let’s say you used whatismyip.com to find that your WAN address is 126.96.36.199
From your control PC (which will now need to be on a different network to really test–use your 3G modem or VPN to another network, or just go to the local coffeeshop WLAN) and type in Terminal:
wakeonlan -i 188.8.131.52 -p 4321 00:11:22:33:44:55
and your PC should have powered itself on.
If it didn’t, try it first using just the LAN with the earlier example–you need to check your BIOS/UEFI settings so that Wake On Lan is enabled. Worst case, you may need to try a discrete Intel Ethernet NIC.