On target (PC to be remotely controlled) do:
sudo apt-get ethtool
- backup your /etc/network/interfaces file:
sudo cp /etc/network/interfaces /etc/network/interfaces.backup
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!
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.
ifconfig and note HWaddr for eth0–this is MAC address
- Reboot remote PC, then shutdown remote PC
On controlling PC, do:
sudo apt-get install wakeonlan
To wakeup remote PC, on your control PC (while on the same LAN), type
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):
Now, that you have that working, let’s do the worldwide version.
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.
Now, 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 220.127.116.11.
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 10.90.80.1 (yes, this example IP is for private networks–I deliberately chose an invalid WAN address for this example)
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 10.90.80.1 -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, available cheaply these days (~$30 at Newegg et al).