Fungible Clouds

Break the cloud services vendor lock-in

Wake a Sleeping Machine From Your Network

| Comments

Most modern computers are capable of Wake on LAN which allows you to turn on a sleeping computer remotely by sending a “magic packet.” Scheduled applications, nighly backup for example, use this feature.

I use this feature to turn on my sleeping iMac when I am away from it but want to log on using ssh (I maintain one Ubuntu machine on the local network that is always running).

The magic packet format is very simple: it must include 6 times hexadecimal FF, followed by 16 times the target machine’s MAC address.

Here is a Python script that will wake up your target machine remotely.

( download
#!/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, ('', 80))

This script assumes that the target machine MAC address is 01-23-45-67-89-0a and that your local DHCP server issues an IP address of to your target machine.

You can run this script from another machine on your local network, like so.

$ python

Got better ideas on waking up sleeping machines remotely when needed? Share below via comments.