Wake a sleeping Mac from the network

Feb 20, '02 09:59:29AM

Contributed by: Anonymous

Most modern computers offer a feature called "Wake on LAN". This is designed to allow a network administrator to turn on a computer remotely, even when it is turned off, by sending a "magic packet". This is used, for instance, to allow backup programs to run at night.

I haven't found any trace of this documented on Apple's web site, but it seems Macs also implement this feature (at least my iMac G4 does). I use this feature to turn on my iMac from my office when I want to log on using ssh (I have a Solaris machine on my home LAN that runs 24/7).

The magic packet format is very simple: it must include anywhere in the packet 6 times hexadecimal FF, followed by 16 times the Mac's MAC address (pun intended). The easiest way to do this is to send a broadcast.

Here is a Python script that does this (if your MAC address is 01-23-45-67-89-0a:

#!/usr/bin/env python
import socket
s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto('\xff'*6+'\x01\x23\x45\x67\x89\x0a'*16, ('192.168.1.255', 80))
[Editor's note: Sounds very cool, but I don't run Python ... any way to replicate this script in something that's installed on all OS X boxes? I know there are a lot of people that would probably be interested in such a solution, myself included!]

Comments (36)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20020220095929695