Things you cannot do with Tclsh

What would you think if you’d receive three queries about the same (somewhat obscure) feature within six hours? It started with a nice e-mail from an engineer that I’ve corresponded with in the past. He wanted to send a Wake-on-LAN packet to a PC in a remote office. Usually you could use the ip directed-broadcast feature, but he wanted to use the remote office router to generate the packet.

A few hours later an engineer from another country that had sent me a few interesting configuration tips a while ago sent an almost identical question:

Since you're a whizz in tcl on IOS, how about a few lines of code to implement sending wake-on-lan magic packets from an IOS router !

To top it off, the following line came not long afterwards from an almost-anonymous source:

Hi Ivan, I have read several articles on your tcl-ios very interesting, I'm learning to use the IOS. Could you say if there is any way to generate a magic packet on ios to boot pc by Wake on LAN? Would be a good entry for your page.

I don't believe in coincidences, so I'm guessing these three engineers were trying to solve very similar problems ... and I keep wondering what happened in their networks in the last week.

Unfortunately, I was not able to help them. The Wake-on-LAN packet has to be sent to the broadcast address and it has to contain pretty long payload, so it's usually sent as a UDP packet (ICMP echo packet would also be an option). Core Tcl supports only socket API and thus does not support UDP (or any other protocol on top of IP but TCP). While various Tcl implementations support UDP with help of external libraries, you cannot use the same libraries in Cisco IOS. So it looks like there's no mechanism to generate a UDP packet with desired payload from Cisco IOS. Am I missing something?

Oh, and there's yet another option: if you can afford to invest $3500 per site, you can install AXP in your router to send the Wake-on-LAN packets.


  1. Hi Ivan,

    is it possible to use EEM/IPSLA to create a probe with one or more UDP packets and defining the content of the packets (multiple MAC address to wake up, I believe) with bcast destination address? We wouldn't use TCL, but EEM can be configured remotely via SNMP...
  2. You gave me an interesting idea ... thanks :)
  3. If you know in advance who is the WOL target, you could probably prepare small file, save it in flash and upload it somewhere via tftp?
  4. Probably won't work unless you have an actual tftp server and span its traffic to WOL target (because tftp needs ack before file if sent).
  5. You also don't appear to be able to write a TCL script, add it as an alias'd command and pipe to it ... something I only discovered *AFTER* writing and testing the script. :'(
  6. The "pipe" is actually part of the "show" command syntax. You can execute the "show" command within the Tcl script with the "exec" command and then filter the results.
  7. Yeah, I've had similar comments from TAC. I think I actually want a "sort" option added to the pipe - on the ASR, "show ip nat translations" is not sorted on inside local (like on most of the other IOS platforms I've run NAT on).
  8. I have an EEM policy that adds a sort option to the command line output modifiers (i.e. things after the pipe). I did it as a proof of concept for adding commands after pipe. Unfortunately it requires EEM version 3.0 and the ASR has EEM version 2.3. The sort is rather rudimentary - throws away lines with too few columns and lines that contain a non-integer value in the specified column, but again it's just a proof of concept.
Add comment