Wake on LAN in the enterprise

Daniel Hagerty hag at linnaean.org
Mon Dec 13 17:47:17 UTC 2010


Owen DeLong <owen at delong.com> writes:

> WOL is unfortunately terribly deficient in that the spec. never =
> envisioned the possibility
> of a need for wake on WAN.
> 
> Bottom line, it's a non-routeable layer 2 protocol. Your choices boil =
> down to the
> helper address nightmare you describe or proxy servers on every subnet.

    WoL works just fine over routed networks; the magic packet format
doesn't preclude it.  I send WoL over routed networks several times a
day.  The only gotcha is that you need some kind of arrangement for
either directed broadcast, or hardcode ndp/arp entries.

Perl code snippet below:

    my $wolhost = "wolhost.example.com";
    my $wolhost_mac = "de:ad:be:ef:ca:fe";

    my $mac = $wolhost_mac;
    $mac =~ s/[: ]//g;

    # Use socat to build a wakeonlan packet inside a udp6 datagram.

    my $packed_bcast = pack("H12", "f" x 12);
    my $packed_mac = pack("H12", $mac);
    my $dgram = $packed_bcast . ( $packed_mac x 16);

    # 9 is the discard port.  For whatever reason, the wrong thing
    # happens when the port is referenced by name, despite having the
    # name in /etc/services.

    open(SOCAT, "|-",
	 (qw(socat -u STDIN),
	  "UDP6-DATAGRAM:$wolhost:9"))
	|| die "popen: $!";
    print SOCAT $dgram || die "print: $!";
    close(SOCAT);




More information about the NANOG mailing list