Configuring Wake-on-LAN

Wake-on-LAN allows you to bring network-connected devices out of standby remotely from another device connected to the same network.  It is a network protocol that was devised in 1997 — around the time when most desktop personal computers (PCs) have power-saving standby modes — probably as a way to remotely wake-up these computers from standby.  Nowadays wake-on-LAN’s more popular uses are to wake-up by network drives (NAS, Network Attached Storage) or Internet of Things (IoT) applications.  Although it is still supported by popular personal computer operating systems to some degree.

Using wake-on-LAN can help reduce your household’s power consumption.  Notably if you use media servers  — file servers containing videos and music — that are not constantly utilized.  The idea is to put these servers to low-power standby and wake it up only when it is about to be accessed.  Consumer network drives would also fall into this category — you don’t need the drive running 24×7 when nobody is at home using it half of the time.  Since drives are mechanical, powering them down would also help prolong their useful lifetime in addition to saving some electricity.

Network cables

The wake-on-LAN protocol works by having a client device broadcasting a special message on the network.  Called “magic packet” this message contains the hardware identifier (its MAC address, in which MAC stands for Media Access Controller and not a line of computers manufactured by Apple) of the target device to be awaken.  In turn, network adapters supporting wake-on-LAN would listen for this “magic packet” and would try to match the MAC address it contains with its own.  Whenever it finds a matching magic packet, the network adapter notifies its host and wakes up the entire system.

However the wake-on-LAN specification does not have a reply.  The standard does not say anything about confirming whether the “magic packet” has been received and a device is in the process of waking up.  Hence wake-on-LAN software would need to use other ways of confirming whether the signal was successful.  Typically this is done by checking whether the device’s last-known host name or IP address is present on the local network and responding to requests.  Worse, some software doesn’t even provide confirmation at all and users would need to verify successful wake-ups themselves.

Setting Up Wake-on-LAN

You would need an application on the client device that can broadcast these magic packets.  This can be as bare-bones as a Python script to just broadcast a hard-coded magic packet or it can also be fully-featured like our Rooster application for the Apple TV which handles device registration and checks for successful wake-up condition apart from just sending the magic packet.

Then you would need a target device to be woken up.  This device would need need to be connected to the same network as the device that runs the client application. That is, it should not pass through more than one router and both the target device and the client device needs to have the same network address mask.

Ideally the wake-on-LAN target is connected via wired ethernet.  Although wake-up over Wi-Fi is possible, our experience seems to show that wired devices setups tend to be more stable as far as wake-on-LAN is concerned. Probably because the wireless network is more susceptible to interferences or many wireless network adapters do not support wake-on-LAN.

You should also make the target device to have a fixed IP address. Fixing the IP address means it doesn’t change between wake-ups and makes it easier for the client application to determine that the device is awaken.  The wake-on-LAN protocol has no response mechanism — the specification does not provide a way for the client to check whether the message was successfully delivered.  Hence client applications would need to check a successful wake-up through some other way — typically by checking whether the target device is responding to network requests through its last-known IP address.

There are two ways to ensure that a device’s IP address remains constant.  One method is by configuring a static IP address.  The other is by configuring the router to always assign the same IP address to the device — a technique called address reservation.

Setting up a static IP address is done on the device itself.  Go to the device’s configuration and configure it to have a “manual address” then give it a set IP address.  The router must also be configured in such a way to not give out this address to another device otherwise a clash will occur.  Note that the subnet mask of the device must match the one configured in the router otherwise the two won’t be able to talk to each other.

IP address reservation is preferred if your router supports it.  To configure this, first you need to obtain the target device’s MAC address — also known as ethernet address.  This is a series of six-digit hexadecimal numbers that identifies the network hardware and is typically burned into the network chip during manufacture.  Having this address, open up the router’s configuration screen which takes care of how it assigns IP addresses to devices  — this is usually labeled like “LAN Configuration” or “DHCP Setup”.  Then the MAC address obtained earlier and assign a specific IP address to it.  Restart the target device and then it should pick up the new IP address.  Some routers would need a restart as well for this configuration to take effect — in these cases, be sure to restart the router first before any other devices that connects to it.

Recommended Setup

This section provides a recommendation for a typical home network setup to support wake-on-LAN and is among the most standard way that a home network is configured. However if you are quite comfortable in setting up your network differently, feel free to skip this section.

Configure your home network to use the IP address range 192.168.0.1192.168.0.254 and the network address mask 192.168.0.255. Also the router needs to have the IP address 192.168.0.1 — the beginning of the range.  This IP address range is commonly used in home LAN and often is the default configuration on many routers.

Then reserve the lower range of these addresses for wired devices or servers.  For example, you could note that addresses from 192.168.0.2 through 192.168.0.15 would be used for servers.  Moreover, servers should be wired as well — since wake-on-LAN works best on wired devices.  To reserve this, you either use a static IP for those devices or obtain the MAC addresses of those servers and reserve them in the router configuration.  If you are using static IP, take care to configure the router so that it will not give out these static addresses to other hosts — use the router’s configuration screen for it.  Since you need to configure the router for both methods, you should use the IP address reservation method if that is supported by the router.

Then you would need to configure the target devices for wake-on-LAN.  These wake-on-LAN target should be connected by cable to the network (wired ethernet).  Moreover these should only have one connection to the network, respectively (that is, one device, one ethernet cable connected and nothing more).

Most consumer NAS are already configured for Wake-on-LAN. We are using WD MyCloud EX2 and the functionality is already enabled out-of-the-box.  However some Synology models do not support wake-on-LAN.  Please check the manual from your NAS’ manufacturer for details on this.

Windows computers need to be configured for wake-on-LAN.  Go to the network adapter, open the Power Management and activate two checkboxes – “Allow this device to wake the computer” and “Only allow a magic packet to wake this computer”. MakeUseOf has a pretty good guide to setup a Windows 10 computer for wake-on-LAN.  Also remember to either reserve an IP address for the computer on the router as described earlier or set a static IP address for it.

By default macOS computers are already configured for wake-on-LAN.  However Mac laptops would only respond to network wake-up requests when connected to power adapter. Configure this in System Preferences then Energy Saver and then enable “Wake for Network Access”.  As with the other server types, we recommend to configure the Mac’s IP address to remain the same between wake-ups and restarts.

Sending Wake-on-LAN Magic Packets

There are a number of solutions to wake devices from the network. These are just some examples:

  • A Python script — send magic packets from just about anything with a Python interpreter.
  • Rooster — an Apple TV app that sends magic packets and has the ability to verify the server has completely booted up.

Troubleshooting Wake-on-LAN

Network Configuration

Check if both devices are in the same IP network — meaning have same subnet mask and able to talk directly to each other without involving any router.  Remember that most routers would not pass wake-on-LAN signals outside its own network.  If one device is a computer, you can run traceroute from the computer into the other device and see how many hops there are to reach it — if there are more than one hops, then you would need to reconfigure your network so that the two is only connected by a single hub or access point.

Router Configuration

Some routers has the ability to filter wake-on-LAN packets even within its own network — probably for security reasons.  Check your router’s manual and configuration screens for details on this.

Software Configuration

Ensure that the wake-on-LAN software that you are using is sending wake-on-LAN signals to the correct MAC address.  You can check the MAC address on the target device itself via its configuration screens or you can check it from a computer located in the same network as the target device.

If you have a macOS computer in your network, you can follow these steps to check the MAC addresses of devices in your network.

  1. Open the Terminal app
  2. Ping the target device using a command similar to the following — change the target IP address to match the wake-on-LAN target.
    ping 192.168.0.2
  3. Run the command below to see all the MAC addresses that is know by the computer:
    arp -a
  4. The previous command lists IP addresses and their corresponding MAC addresses. Look for the target device’s IP address and its corresponding MAC address
  5. Compare this MAC address with the one configured in your wake-on-LAN software.

Target Configuration

Make sure that the target can respond on wake-on-LAN packets.  Furthermore you should configure the target in such a way that IP address doesn’t change before wake-up and after wake-up.

Similarly you would need to verify that the MAC address doesn’t change between reboots of the target device. Some devices do this for security reasons.  Unfortunately this makes it a poor wake-on-LAN target.

Windows machines only support wake-on-LAN on certain sleep modes.  The computer would only respond to wake-up signals from regular sleep (S3 mode) or if the user specifically requested hibernate (S4 mode). Hence it is best to just use regular sleep on Windows machines to be used as wake-on-LAN targets.  Refer to System Power States for more information.

A Message from the Sponsor

This article is brought to you by Rooster – the wake-on-LAN app for tvOS.  With Rooster you can keep your network drives hosting your video files on sleep mode most of the time and activate them when you need to watch videos — right from your Apple TV — without leaving your sofa. Prolong your NAS’ lifetime, save electricity, and be greener with Rooster for tvOS.


Subscribe

Get articles like this sent to your inbox as soon as they are published.

* indicates required

Unsubscribe any time and we won't share your details with third parties.

Tags: , , , , , ,