Wake On Lan

(From Wikipedia) Wake-on-LAN is an Ethernet computer networking standard that allows a computer to be turned on or woken up by a network message.

If you want to wake your computer up from the outside of LAN, it’s mostly about your router. I’ll give a shot to explain how it works for me.

First you should install ethtool on which box you’re planning to wake up. And check the ethernet card if its wol capable with a command like “ethtool eth0”. You probably will see something like “Wake-on : d” if it’s clever enough, you should change this to “g” with this command:

ethtool -s eth0 wol g

It’s better to add this command to an init script (best choice looks like /etc/conf.d/local.start for openrc). And don’t forget to check MAC address of the network card (e.g ifconfig | grep HWaddr ).

Now you can switch off your box and wake it up from another LAN client with sending a magic packet to its MAC (wakeonlan XX:XX:XX:XX:XX:XX). You just need to install “wakeonlan” package.

What about outside of local network? Well, wakeonlan uses 9th UDP port by default. I found a solution in ArchLinux wiki. First you should connect to your router (with ssh, telnet or something) and forward a special IP to special MAC address (in this case, your box’s MAC) E.g:

arp -s XX:XX:XX:XX:XX:XX

And now, forward your 9th UDP port to from your router’s interface. Now you can send magic packets to your router’s IP from internet. It should be like:

wakeonlan -i IP_ADDRESS -p 9 XX:XX:XX:XX:XX:XX

It’s better to set up a dynamic dns if you’re using dynamic IP. For this case, i wrote a dirty script to wake my computer up from internet to solve IP address and send the package. With using your box’s MAC address:

IPWTF=`ping -c 1 dynamic_dns_address_of_your_box.com | grep "bytes of"| awk '{ print $3 }' | sed '1s/^.//' | sed '$s/.$//'`
wakeonlan -i $IPWTF -p 9 XX:XX:XX:XX:XX:XX

Don’t forget to establish a ssh connection to switch it off :) Have fun!

More info:


347 Words

2010-03-08 09:37 +0100