Turn On Home Ubuntu Computer When You are Not Home On Demand

You can turn on any computer remotely using Wake-on-LAN (or WOL). It's really handy if you need to grab a file from your home computer but you don't want to turn on that computer 24/7 just for one file.

Requirement:
  1. You need to know something about computer/Bios/LAN/Router as I can't explain everything here.
  2. You need to somehow able to be in your home LAN.  Possible methods:
    1. You can VPN back to your home network.
    2. You can ssh back to your home server (This is what I do)
    3. You forward port 0,7 or 9 on your home router to your computer. (highly NOT recommended since everyone will be possible to turn on your computer)
Steps:
Let's call your home computer "Computer A" and your other computer "Computer B"

In "Computer A"
  1. Go to your BIOS, and turn on WakeOnLAN. I might be called something else. Look for something like "Wake On Lan," "Remote Wake Up" or etc.
  2. Turn on WOL
    1. Find out your network interface name by "ifconfig". Normally it's similar to "eth0."
    2. Turn on WOL

      ethtool -s eth0 wol g
      Since the effect of this command only last till next restart, you will need to set up a script to turn it on every time you start your "Computer A" - See Reference 1 - http://ubuntuforums.org/showthread.php?t=234588 for detail
    3. Find out your network interface's MAC address

      ifconfig | grep HW | cut -d' ' -f11-
      it's something like "12:34:56:78:9a:bc". Copy it down and turn off your computer.
    4. (Optional) If your "Computer B" is a Windows machine, you will also need to find out Computer A's ip address.

      ifconfig | grep "inet addr" | cut -d' ' -f12-12| tr -d 'adr:'
      It will look like '192.168.1.127'
In "Computer B"
  1. If it is a Ubuntu or any other Linux distro.

    wakeonlan 12:34:56:78:9a:bc
    the above command should be sufficient.  If it doesn't work, try the command again with port 7.

    wakeonlan -p 7 12:34:56:78:9a:bc
  2. If it is a Windows machine, try the following.

    wolcmd 123456789abc 192.168.1.127 255.255.255.255 7
Hope it helps someone.

Reference:
http://ubuntuforums.org/showthread.php?t=234588
http://en.wikipedia.org/wiki/Wake-on-LAN
http://en.wikipedia.org/wiki/Wake-on-LAN#Sending_the_magic_packet

No comments: