visit
Step 1: Satisfy hardware requirements
In most motherboards, there is a function called “Wake-on-Lan” (WOL). WoL works by sending a packet of data called a Magic Packet™ to a target machine. When the packet is received, the target machine’s network interface wakes-up the rest of the computer. However, I recognized that I cannot wake-up my server through its wireless interface (I’m using a USB wireless adapter). It turned out that the Magic Packet must be sent to the motherboard’s built-in Ethernet port since it’s the only thing awake when the whole machine off. I fixed the situation by using a Wifi Repeater, and connect it to the server through an Ethernet cable. You can skip this step if your machine is using a wired connection.
Step 2: Make Wake-On-Lan work on Lan.
$ route #Get name of the default interface, for example: eth0$ sudo ethtool eth0#Look for "Supports Wake-on: g" line, which means WOL supported$ sudo ethtool -s eth0 wol g #Enable WOL
To make the setting sustains after rebooting, you need to add the last command above to the interface’s configuration in etc/network/interfaces. You can read more in .
Now, let’s test it. You can use a mobile app called “Wake-on-Lan” in Android (there are similar apps for iOS, but I haven’t tested it). It can automatically scan your local network and list all of the connected devices. You just search for your machine, add it, and then you can send the magic packet to it whenever you want. Try to turn off your target machine and wake it up by your phone.You can add the device manually if you know its mac address and broadcast address. They are 9E:65:F9:0E:29:FB and 192.168.0.255 in my case. You can use the ifconfig command to find out that information. Note that you will need your mac address to wake up your machine through the internet.
Step 3: Make Wake-On-Lan work through the internet.
Note that your router must have a static IP (i.e., 82.164.3.27) to complete this step. There are many solutions to send the magic packet through the internet. I’ve listed them below from the easiest to the hardest (sometimes the only) solution:
First solution: If your router supports forwarding the magic packet (Port 7 or 9 UDP), you are lucky. You can just forward any packet from port 7 or 9 UDP to your target device. Some routers even allow forwarding broadcast packet. You can use to wake up your server. However, as far as I know, most of the popular commercial routers do not support this (my case). Remember to make a DHCP reservation for your server, so that its IP will not change after reconnecting.
Second solution: You can check if you can install a better firmware for your router. For marketing purpose, many router producers hide functionalities on their products. You can install a third-party firmware to unlock all of these. I highly recommend the . Check if your router is supported by OpenWrt .
Third solution: If your router is not that good, you will need an insider. It’s a device that is always on and connects to your local network. Then you can SSH to your insider over the internet and let it send the magic package for you. In my case, I use a cheap Raspberry Pi 3 (which I already use for controlling other things). I’m using OpenWrt on it, and run the etherwake command as following:
$ etherwake 9E:65:F9:0E:29:FB eth0 The first argument is the mac address of the target machine, while the second argument is the network interface of the insider that will send the package. It should be its default interface. You can check for more detail. Note that your insider can be any device, running any OS. As long as you can SSH to it through the internet, it should work. Remember to configure port forwarding for the insider’s SSH port, so that you can SSH to it from anywhere. So, that’s it. I hope you enjoy the story. Leave a comment if you have any trouble following it.