19

Either some (preferably free/OS) app or a command line tool will do.

3 Answers 3

12

Try WakeOnLan or wol — both are open source, both are available through MacPorts (and possibly through Homebrew as well).

1
  • 1
    WakeOnLan appears to no longer be available - the readpixel.com site linked above is being flagged as malware by Chrome, and it was also recently removed from homebrew-cask - github.com/Homebrew/homebrew-cask/issues/104849. I'd recommend using the open-source perl script from the homebrew formula in the answer below.
    – AlexT
    May 9, 2021 at 9:24
19

Install the wakeonlan package using Homebrew:

$ brew install wakeonlan

(It's a Perl script for waking up computers via Wake-On-LAN magic packets.)

When installed, you can send a "magic packet" from your Terminal to any device using its IP (Internet Protocol) and MAC (Media Access Control) address.

Here's an example of a typical use:

$ wakeonlan -i 192.168.1.255 -p 1234 01:02:03:04:05:06

The scripts takes 2 arguments, the MAC address of the NIC, and an IP address.

Note: The IP address argument is tricky and isn't what you'd think.

For a NIC on your local subnet, use the broadcast-address of this subnet. (e.g. subnet 192.168.10.0 with netmask 255.255.255.0, use 192.168.10.255)

For example, I have a Synology NAS manually configured with the IP address of 10.0.1.100 with a subnet mask of 255.255.255.0 and a router address of 10.0.1.1.

The correct IP address to use is not that of the device, but instead the broadcast-address of the subnet.

Continuing on my example, I used the following command to successfully wake up my Synology:

$ wakeonlan -i 10.0.1.255 -p 7 01:02:03:04:05:06

(Naturally, substitute the actual values of your device and network for your situation.)

You can get more information from the wakeonlan man page, man makeonlan, or a quick glossary of commands from wakeonlan -h.

4
  • 1
    Just a slight hint: looks like the command has three parameters, for -i the broadcast address (not the IP address), for -p the magic packet (which you do not explain, looks like you are showing 1234 or 7 as magic packet) and third parameter is the Ethernet (or MAC-) address. Jul 1, 2019 at 12:32
  • 1
    @pebwindkraft , -p sets the destination port, actually (and defaults to 9).
    – user820330
    Jul 29, 2019 at 11:21
  • 1
    FWIW, straight out of the box this worked for me to wake an Intel NUC using just wakeonlan 94:c6:91:a1:68:22. No parameters necessary. To be fair, the NUC is on my home LAN and I got the MAC address by running arp -a and recognising the IP address, so obviously the ARP table was still valid. Sep 3, 2022 at 12:25
  • Like @HeathRaftery, I experienced the same — no need for any extra parameters. It actually makes some sense: on most LANs, you just need to broadcast on the segment where you are. The only reason for having this extra -i option is if you've got a router or bridge or similar multi-networked device, and have to specify in advance which device/network to use... Feb 21 at 0:03
0

install:

# create a binary dir (-p, avoids error if dir exists)
mkdir -p $HOME/bin

# download the script
curl https://raw.githubusercontent.com/jpoliv/wakeonlan/master/wakeonlan -o ~/bin/wakeonlan
# give execution permission

chmod +x ~/bin/wakeonlan

wake:

~/bin/wakeonlan THE_MAC_ADDRESS
2
  • Could you expand your answer to explain what these commands do?
    – Burgi
    Feb 25, 2016 at 14:50
  • mkdir: make ad new directory; curl: Download "wakeonlan"; ~/bin/wakeonlan: execute the downloaded script.
    – B.Bippus
    Feb 27, 2016 at 15:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .