I have setup
wake on lan service on my server. Everything works fine on local area network:
root@server$: poweroff user@local$ wakeonlan AA:BB:CC:DD:EE:FF
and the server wakes up.
AA:BB:CC:DD:EE:FF is a MAC address of my
server, which has IP
192.168.1.2 and hostname:
example.com. It is connected to the router, which has IP 192.168.1.1 (public: xxx.xxx.xxx.xxx)
When the server is up, I can ping:
or login via ssh:
So far, so good. Now I'm able to wake the server up from local area, but how to wake the server from the remote location?
user@local$ wakeonlan -i xxx.xxx.xxx.xxx AA:BB:CC:DD:EE:FF, but it does not work (nothing happens;).
Do I have to configure my router somehow to forward magic packets? How?
After Ragnar's answer the solution looked very easy.
But actually, it was a bit tricky.
My router is
Linksys WAG200g, which does not support Wake on LAN by default. Furthermore, it does not allow to forward to triplets above
254 (my broadcast address was
The solution was to forward UDP port
7 to the address of the server, which was
18.104.22.168, then call:
wakeonlan -i example.com -p 7 AA:BB:CC:DD:EE:FF
Also I installed new firmware:
which is a great router options upgrade (e.g. adds Wake on LAN option).
I also changed my netmask from
255.255.255.128, so my broadcast is now
192.168.1.127 and passes the router validation rules.
Here is the script I use to connect to the machine, and wake it up if needed:
#!/bin/bash ## This sends magic packets to Wake on Lan ## please note, you must formard port 7 to the target machine on your router ## host to wake up host="example.com" ## mac address of the machive to wake up mac="AA:BB:CC:DD:EE:FF" ## user to login user="administrator" echo "Looking for $host..." wget -q --tries=2 --wait=1 --waitretry=5 http://$host/ if [ $? -ne 0 ]; then echo "$host is not available." echo "Waking up $host." wakeonlan -p 7 -i $host $mac echo "$host is booting up. Please wait..." sleep 30 wget -q --waitretry=5 --wait=5 http://$host/ echo ^G echo $host is up! Lucky you! fi ssh "$user@$host"
Don't forget to install: wakeonlan