Sunday, September 21, 2008

How To Remotely Boot Up and Shut Down a Computer

On my local network at home, I have a MacBook and several "headless" Linux boxes, which I use to crunch numbers. Other people might have a headless computer on their network used as a file or web server. Some computers on your local network may be in another room or even in a different country if you have a VPN setup. I found that I needed a way to remotely boot up and shut down any host on my local network without leaving my chair. How could I possibly do this all from the command line on my mac?

The setup and implementation is extremely easy - if you know what to do! It took me several hours to get it all working, but I'll summarize the steps here for you and it should only take about 30 minutes maximum to setup. The instructions below are specific to booting up and shutting down a remote host running Ubuntu Hardy Heron from a Mac running OSX Leopard, but other combimations of OSs will also probably work with possible slight variations to the instructions.

1. Enter the BIOS of the remote host you want to remotely boot up/shut down and enable the Wake On LAN feature (WoL). Save changes and exit BIOS.

2. Boot up the remote host and determine its IP and MAC address by typing ifconfig at the command line. The IP address will look something like this: For the MAC address, you'll need to look for the 6 hexidecimal numbers separated by colons in the text returned by the ifconfig command. It will look something like this: 00:78:A5:9C:E8:AB. Write it down.


3. Shut down the remote host.

4. Download Wake-On-LAN (wakeonlan-0.41.tar.gz) here to your mac. It's a Perl script written by José Pedro Oliveira that sends a magic packet to LAN cards connected to your local network. More information on how WoL works can be found here.

5. Open up "Terminal" on your Mac, and un-tar the tar.

-->tar -xvvzf wakeonlan-0.41.tar.gz

6. Move the wakeonlan executable file to /usr/bin to have access to the script via the command line.

-->cp wakeonlan /usr/bin

7. To remotely boot up the remote host, type at the command line: wakeonlan -i [local network domain] [MAC address] & , where the local network domain is a 4 number address separated by periods - the first three numbers match the first three numbers of the host's IP address and the last number is 255. The MAC address corresponds to the MAC address of the host you're trying to boot up.

-->wakeonlan -i 00:78:A5:9C:E8:AB &

8. To remotely shut down the host, ssh into the host and type:

-->sudo shutdown -P now

Piece of cake!

1 comment:

Anonymous said...

Yey another way to wwakeup remotely is an online service