As you know, here at AnyPcFixed we are enthusiasts at heart. When we were faced with a problem of needing to switch one of our machines on away from home so that we could remotely access it for a few files, we had a little think and found a very nice way to do it …. we rang home and asked somebody at the house to switch the computer on for us. Simple solution 🙂 Funny for us, not so funny for them especially when you’re hassling them several times in a week!
Shutting it down isn’t a problem as you simply shut down from the start menu whilst remotely logged in, so we shut it down in our own time once we were finished. We didn’t need anybody on the other end to help with that.
Amusement aside (and being a nuisance to our loved ones) yes we did find a technical way to achieve this so that we weren’t reliant on somebody being at home. And it’s called ‘Wake On LAN’, or WOL as it’s referred to amongst corporate computer users. It is a feature where if the computer is both connected to the mains (but is physically off), and the network adapter’s ethernet port is connected to your network via a router, it can be switched on by sending it what we call a ‘magic packet’. This will awaken the PC; in other words, turn it on. If the PC is in sleep or hibernation mode, it’ll also awaken it so this can work if you’ve left your machine in sleep mode too whilst away. Have you ever noticed that the small LEDs on the ethernet port at the rear of a computer are always blinking, even when the machine is turned off? This is because the network adapter stays ‘on’ in a very low power mode if a network cable is attached. If the machine isn’t connected to a live mains outlet, this won’t work so the machine needs to be connected to a live mains outlet even whilst it is off.
Not all computers will have this feature though. It’s not always called ‘WOL’ either. On many aftermarket computers the feature is more commonly known as ‘Remote Wakeup’. It’s always present in business/corporate client workstation computers, notably Dell Optiplex machines or HP Elitedesk machines for example. It’s a very old protocol so it’ll be present on workstation machines as old as the early 2000’s. It makes it easy for a network administrator to switch several hundred machines on via the server within an office complex or an educational establishment without going room-to-room manually switching them all on. With a few twists and the help of some cheap modern hardware, we can leverage this function at home to allow us to switch a machine on away from the physical network by using the internet.
This is what we are going to do:
- Purchase a Raspberry Pi 2 Model B+. It doesn’t have to be the latest one (currently the Raspberry Pi 3), it just needs to have an ethernet port to connect it to our router. A Raspberry Pi Zero won’t be suitable without also getting a USB ethernet adapter – it’s more convenient to get a full Raspberry Pi. Besides, we’ll be able to use it for more purposes than just WOL – more on this another time.
- Set up Raspbian OS on an SD Card and boot the Pi up with it.
- Plug the Pi into the mains outlet, and hook the ethernet port up to the router with an ethernet cable.
- Find out the IP address that the Pi has been given by the router.
- Make a note of the MAC Address that the computer’s network adapter has.
- Using SSH on our PC, log into the Pi.
- Set up a web server on the Pi.
- Create a blank PHP web page that runs a WOL command to wake up the MAC Address of the computer. Raspbian will already have the ‘wakeonlan’ package.
- Change the usual HTTP web server port to a different one, mainly for security reasons. Set up port forwarding of this port with the router, to allow access to the Pi’s web server from outside the home network via the internet.
- On our smartphone, set up a shortcut in your web browser to the PHP page we created, by using our IP Address given to us by our ISP (or use a DDNS service if your IP Address is dynamic) and the HTTP port we set up.
Now, to switch the computer on from anywhere in the world as long as we have internet, all we need to do is enter the web address in of our PHP page we created, and our computer will be switched on via WOL. For example, http://IP:PORT/home-computer.php where IP is the IP Address of our home internet connection, and the PORT is the port that we allocated to the web server. This can be anything between 49152 and 65535. The file ‘home-computer.php’ is the PHP script that contains the ‘wakeonlan’ command with the MAC address of our computer.
We are avid users of Teamviewer for remote access and remote support. All we need to do once visiting our PHP script is await our computer to come online in our Teamviewer client list. Since our computer is SSD powered, it’s usually on within 10 seconds. Once it appears, we can log in remotely, enter our login password for Windows, and we’re in! Use the computer, do what we need to do, grab a few files, check a few things, and then once done shut the computer down.
Of course you need to make sure you have internet wherever you are to access the PHP script. Without any form of internet access, you will be unable to switch the computer on. The only other requirement is to have left it plugged into a live mains outlet at home and connected to your router via ethernet, which we’re assuming you already leave on 24/7. Oh, and the Pi needs to stay on 24/7 also. Power consumption is next to nothing so there’s no need to worry about elevated electricity bills. If anything, you’ll save money because before being able to do this, you may have had to leave your PC permanently on at home whilst away. This way, you can leave it shut down or in a sleep mode.
If you would like to add this feature to your home technology arsenal (providing your home computer has WOL support), then contact us and we can prepare a Raspberry Pi for you. All that we’ll charge is the cost to cover a Raspberry Pi, and a small amount of money to cover a little of our time in setting it all up for you. Once everything is set up, you can simply plug it into your home network and off you go!
Just to note, the Raspberry Pi 3 has built-in wireless, and if you don’t have any free ports on your router for the Raspberry Pi then we can set it up so that it connects to your router via wireless instead. This also means you can plug the Pi in anywhere at your home as long as wireless strength is average in that area of your house. It doesn’t have to be in close proximity to the router.
It still amazes us what can be accomplished with cheap embedded computing. This isn’t the end. The very same Pi can still be used to run other things concurrently for other nifty additions to your household. After all, it’s already being left powered on 24/7, and the demands of running a web server are non whatsoever. Watch this space, as in a future post we add another little twist to the above to show you how you can switch your computer on verbally by using an Amazon Echo or Echo Dot! Utilising the very same PHP script that we created above.
All that would need to be done now is to either make or purchase a small box to house the Pi, to neaten things up a little.
Thanks for reading!