Version 7 of Generating The Wake On Lan Magic Packet

Updated 2006-02-08 08:59:52

2006-02-06 SRIV I've always wondered how to utilize the Wake On Lan feature of modern computers, especially since last night when I had to halt a machine 200 miles away and I had no one there to power it back up.

After you enable WOL in you motherboard's BIOS, boot into your OS. I typically use Linux. In order for the halt command to power down the computer you must have the apm module loaded first. Now, issue the halt command, and the computer should turn off, but, the LAN jack indicator LEDs should still be lit.

Run this script, passing the IP Address and MAC address of the computer's NIC on the command line:

  wakeonlan.tcl 192.168.0.55 00:40:63:D5:2A:B9

and you will note that the computer will power on. You'll need to obtain the tcludp extension as well.

  # wakeonlan.tcl -  Steve Redler IV
  #
  # Create and send the magic packet needed to wake a halted
  # computer over the internet via broadcast UDP socket.
  #


  package require udp 1.0.8

  # Select the ipaddress and the port number.
  set ipaddress [lindex $argv 0]
  set port   32767

  # Create a broadcast sending udp socket.
  set s [udp_open $port]
  fconfigure $s -buffering none -blocking 0
  fconfigure $s -broadcast 1 -remote [list $ipaddress $port]


  # Generate and send the magic packet
  set hw_addr [binary format H* [string map {: ""} [lindex $argv 1]]]
  set msg "\xff\xff\xff\xff\xff\xff[string repeat $hw_addr 16]"
  # Lets send it 4 times to be safe
  for {set a 0} {$a < 4} {incr a} {
    puts -nonewline $s $msg
    after 100
  }

  exit

2006-02-08 You'd better send this to the subnet broadcast IP address 192.168.0.255 - JR


Category Networking