Sending WakeOnLAN Magic Packets

Waking up Sleeping macOS Computers


There exists in this magical world of computers we inhabit an entity known as the Magic Packet, which when sent to a sleeping computer magically wakens it from its slumber. This is very useful if you need to access remote machines that have gone into hibernation/sleep mode. This system is known as WakeOnLan.

The ability to send Magic Packet is available on most systems, including Windows and Linux but as I only have direct experience of doing this with OSX and latterly macOS, that’s what this post will cover. However I think most of what I say here will be applicable to those other platforms as well. YMMV!

Make Sure Your Machines Are Listening

On the machines that you want to be able to wake up remotely, go to the Apple menu () at the top left-hand corner of the screen and open up System Preferences on macOS. When System Preferences opens, select the Energy Saver :bulb: option and make sure Wake for network access option is ticked like so:

System Preferences Energy Saver Tab

Wake for Network Access

With the option checked your computer is now configured to listen for the Magic Packet. 1

Installing Wakeonlan

You have a couple of choices when installing wakeonlan.

The first option and the one I would definitely recommend is using the Homebrew package manager because it’s a simple and easy to install, update and upgrade tools once you have installed them. Instructions on how to install Homebrew are outside the scope of this post, but it’s not very difficult and you can find Homebrew installation instructions here.

You can also download a Perl script from to somewhere on your computer and run it from there.

Installing with Homebrew

To install wakeonlan using Homebrew it’s as simple as running this command:

Install WakeOnLan

brew install wakeonlan

And that’s it, you can now run wakeonlan from anywhere on your computer and have it work, rather than having to provide the full path to the program each time you want to run the tool.

Installing from Github

CAVEAT CODER: As always, when downloading a script from the Internets make sure you have a look at what it’s doing before you run it just to make sure it’s not doing anything malicious. As far as I know this one isn’t, but I’m not responsible if you get r00ted because someone has tinkered with this command.

With that out of the way, let’s install the script. The commands below will first create a folder to put script in, second it will download the script and lastly it will make the script executable so that you can run it.

Downloading the Perl Script

# Create a directory for the script
mkdir -p $HOME/bin
# Download the script to your new directory
curl -o ~/bin/wakeonlan
# Make your script executable
chmod +x ~/bin/wakeonlan


Finding the Right MAC Address

You will need to know the MAC address of the machine you are trying to wake up for this to work. There are tons of ways of doing this, but three of them are:

  1. Download the very excellent wakeonlan for macOS 2 and click Scan. It’s that simple to use and will return a list of all of the devices on your network with their IP addresses and associated MAC addresses.
  2. Download the iOS app Fing to your phone or iPad, click Scan and again a list of IP and Mac addresses will be returned to you.
  3. But my absolute favourite option is to install nmap using Homebrew and then use the command sudo nmap to scan a whole network and return MAC addresses amongst lots of other useful and juicy information about the machines on your network. You can also target specific machines with nmap using the command sudo nmap, but this relies upon you knowing the IP address of the machine you’re targeting.

Sending the Magic Packet

Installation Location

If you installed wakeonlan using Homebrew, then you can just use the command wakeonlan from anywhere inside your terminal. However if you downloaded the script from Github you will need to used the full path to the command each time you want to use it. So for instance you would have to use .~/bin/wakeonlan rather than simply using wakeonlan.

So, we have now installed the requisite software and we want to wake up a slumbering machine somewhere in the house, we’ve used one of three methods above to find out its MAC address so all we need do is issue the command:

Sending Magic Packets

wakeonlan 00:11:22:33:44:55

If you were successful you should see something like this message returned to you in your Terminal:

Successful Message

Sending magic packet to with 00:11:22:33:44:55

If it doesn’t respond with a successful message then you may need to specify the IP address and/or the SSH report of the machine you’re trying to wake up. That command looks like this:

Alternative Magic Packet Sending

wakeonlan -i -p 22 00:11:22:33:44:55

You can also send a Magic Packet to any number of computers at once by passing in a file containing a list of Mac addresses of the machines you want to wake up to the wakeonlanscript. Like so:

Using a File to Send Magic Packets

wakeonlan -f file-containing-mac-addresses.txt

And that in a nutshell is how to use the wakeonlan tool. As always if you have any questions just drop me a line. Feel free to hit me up on Twitter about anything, I’m @escapologybb and @robotsandcakes

  1. You will need to plug your laptop into the mains for this to work. 

  2. This tool is reasonably old so should work with Apple OSes as far back as when it was called OS X!