Part 7: How to wake up your computer (at home over the internet)

You can easily download a program called WakeUpOnLan for Windows -- but the problem with this is that it won't work over the internet. It only works on local networks. So, to wake up your home computer, you'll have to ssh to your linux server (Fishbuntu) and send the wakeup signal from it by running a script which I call "wakemeup".

1. You will have to find out the MAC address of your Ethernet card, by going to a command prompt (on your windows desktop - the computer you want to wake up) and typing "ipconfig /all". Look for the line that says "Physical Address" and copy the numbers down.

C:\>ipconfig /all Windows IP Configuration Host Name . . . . . . . . . . . . : aaaaaaaaa Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Unknown IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Intel PRO/100 blah blah blah blah blah blah blah blah blah Physical Address. . . . . . . . . : 00-AB-55-FC-21-C6 Dhcp Enabled. . . . . . . . . . . : No IP Address. . . . . . . . . . . . : 192.168.1.4 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 DNS Servers . . . . . . . . . . . : 200.222.3.1 200.222.3.2


2. You'll need two files which have to be in the same directory:

-rwxr--r-- 1 fiona fiona 33 2009-03-10 20:22 wakemeup
-rw-r--r-- 1 fiona fiona 3086 2009-03-10 20:19 wakeup.pl

The "wakemeup" file has the following two lines in it:
May sure that you type in your MAC address from step 1.
echo "Waking up desktop ..." perl wakeup.pl 00:AB:55:FC:21:C6
Then copy the following into a file called wakeup.pl . I got it from somewhere like this.
#!/usr/bin/perl -w # # If called as wake.pl -f file it reads lines of the form # # aa:bb:cc:dd:ee;ff 12.34.56.78 or # aa:bb:cc:dd:ee:ff foo.bar.com # aa:bb:cc:dd:ee:ff # # which are MAC addresses and hostnames of NICs to send a wakeup packet. # In the first two cases, unicast is used (and root permission may be # required if the ARP cache needs to be injected with a mapping). # In the third case, broadcast is used, and anybody can run the command. # Comments in the file start with #. # # Or MAC addresses can be specified on the command line # # wake.pl aa.bb.cc.dd.ee.ff # # Or both can be used: # # wake.pl -f addresses.cfg 11:22:33:44:55:66 # # This program may have to be run with superuser privilege because it # may need to inject an ARP entry into the cache. # Be careful, you could corrupt valid entries if those NICs are # already active. # # Perl version by ken.yap@acm.org after DOS/Windows C version posted by # Steve_Marfisi@3com.com on the Netboot mailing list # Released under GNU Public License, 2000-01-05 # use Getopt::Std; use Socket; getopt('f:', \%opts); if (exists($opts{'f'})) { unless (open(F, $opts{'f'})) { print "open: $opts{'f'}: $!\n"; } else { while () { next if /^\s*#/; # skip comments ($mac, $ip) = split; next if !defined($mac) or $mac eq ''; if (!defined($ip) or $ip eq '') { &send_broadcast_packet($mac); } else { &send_wakeup_packet($mac, $ip); } } close(F); } } while (@ARGV) { send_broadcast_packet(shift(@ARGV)); } sub send_broadcast_packet { ($mac) = @_; if ($mac !~ /[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}/i) { print "Malformed MAC address $mac\n"; return; } print "Sending wakeup packet to MAC address $mac\n"; # Remove colons $mac =~ tr/://d; # Magic packet is 6 bytes of FF followed by the MAC address 16 times $magic = ("\xff" x 6) . (pack('H12', $mac) x 16); # Create socket socket(S, PF_INET, SOCK_DGRAM, getprotobyname('udp')) or die "socket: $!\n"; # Enable broadcast setsockopt(S, SOL_SOCKET, SO_BROADCAST, 1) or die "setsockopt: $!\n"; # Send the wakeup packet defined(send(S, $magic, 0, sockaddr_in(0x2fff, INADDR_BROADCAST))) or print "send: $!\n"; close(S); } sub send_wakeup_packet { ($mac, $ip) = @_; if (!defined($iaddr = inet_aton($ip))) { print "Cannot resolve $ip\n"; return; } if ($mac !~ /[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}:[\da-f]{2}/i) { print "Malformed MAC address $mac\n"; return; } # Inject entry into ARP table, in case it's not there already system("arp -s $ip $mac") == 0 or print "Warning: arp command failed, you need to be root\n"; print "Sending wakeup packet to $ip at MAC address $mac\n"; # Remove colons $mac =~ tr/://d; # Magic packet is 6 bytes of FF followed by the MAC address 16 times $magic = ("\xff" x 6) . (pack('H12', $mac) x 16); # Create socket socket(S, PF_INET, SOCK_DGRAM, getprotobyname('udp')) or die "socket: $!\n"; # Send the wakeup packet defined(send(S, $magic, 0, sockaddr_in(0x2fff, $iaddr))) or print "send: $!\n"; close(S); }

3. Finally, on your desktop computer, you'll have to change the settings to allow WakeOnLan.
There are two possible places to do this: I have done both, but one or other may suffice.

  1. BIOS (figure this out by looking at your BIOS settings)
  2. Network card settings (see below)

DONE. This should now work. You can wake up your compluter whether it is off or hibernating.
Test it by typing in ./wakemeup after you have connected to Fishbuntu using SSH.