wake on lan / wol with linux in IPv6-LAN (without IPv4)

Bjørn Mork bjorn at mork.no
Tue Sep 16 14:34:13 CEST 2014


Ignatios Souvatzis <ignatios at cs.uni-bonn.de> writes:
> On Mon, Sep 15, 2014 at 07:46:04PM +0200, Thomas Schäfer wrote:
>
>> I am still looking for an IPv6-wol (without mono)
>
> I suspect that sending to the all-stations multicast would work, wouldn't
> it? The hardware detects the magic pattern anywhere in the packet.
>
> Thinking about it - it should work whether the target machine uses IPv6
> in normal operation or not.

This depends on all-stations multicast being forwarded to inactive
ports. If it works with your switches, then fine.  But I don't think you
can assume it works everywhere.

You could try something like this (might need a bit more error
detection...):

#!/usr/bin/perl
use Socket;
use Socket6;
my $iface = shift;
my $mac = pack("C6", map { hex } split(/:/, shift || die "Usage: $0 <iface> <mac>\n"));
socket(S, AF_INET6, SOCK_DGRAM, 17);
require "sys/ioctl.ph";
ioctl(S, &SIOCGIFINDEX, $iface);
setsockopt(S, IPPROTO_IPV6, IPV6_MULTICAST_IF, substr($iface, 16));
send(S, pack("C6", (255) x 6) . $mac x 16, 0, pack_sockaddr_in6(7, inet_pton(AF_INET6, "ff02::1")));


But IP(v4) broadcast has the advantage that it will be forwarded to all
ports in the L2 broadcast domain.  That's why it is often used for
non-root wake-on-lan tools.  I guess it's easier/better to just add a
dummy IPv4 broadcast route if you want to enable non-root users to send
wol packets.


Bjørn



More information about the ipv6-ops mailing list