LoginSignup
3
4

More than 5 years have passed since last update.

Wake On Lanについて

Last updated at Posted at 2019-01-16

概要

Wake on Lanについて調べた情報を整理する。

規格

きちんとした国際規格はなく、デファクトスタンダードがあるらしい。
詳細は以下の通り。

マジックパケットは、FF:FF:FF:FF:FF:FFに続けて起動したい装置のMACアドレスを16回繰り返したデータパターン(AMD Magic Packet Format) がペイロードのどこかに含まれているようなパケットである。例えば、起動したい装置のMACアドレスが EE:EE:EE:00:00:01 の場合、

FF:FF:FF:FF:FF:FF EE:EE:EE:00:00:01 EE:EE:EE:00:00:01 EE:EE:EE:00:00:01 EE:EE:EE:00:00:01 EE:EE:EE:00:00:01 EE:EE:EE:00:00:01
EE:EE:EE:00:00:01 EE:EE:EE:00:00:01 EE:EE:EE:00:00:01 EE:EE:EE:00:00:01 EE:EE:EE:00:00:01 EE:EE:EE:00:00:01 EE:EE:EE:00:00:01
EE:EE:EE:00:00:01 EE:EE:EE:00:00:01 EE:EE:EE:00:00:01

このような102バイトの信号が含まれるパケットが送られ、ターゲット機器にそのパケットが届くと、102バイトの信号を認識して電源ステート(例えば ACPI S ステート)が切り替えられ、装置の電源が入る。

最初の6バイトのFFはブロードキャストを表すあて先 MAC アドレスではない。Ethernet フレームの先頭からこのパターンを開始すると EtherType フィールドが本来の意味ではなくなってしまう。通常はポート 7 または 9 の UDP パケット、あるいは EtherType=0x0842 の Ethernet フレームのペイロードに埋め込まれる。

ターゲット機器はネットワークアダプタに通電こそされているものの、マジックパケットを待ち受けることしかしない状態であり、通常の IP や ARP に反応することはない。そのため、IPアドレスや MACアドレスでの到達性が保障されないため、マジックパケットは Ethernet ブロードキャストフレームとして送信されなければならない。

https://ja.wikipedia.org/wiki/Wake-on-LAN より引用

特長

  • 規格に書いたとおり「Ethernet ブロードキャストフレームとして送信されなければならない」ので、同じLANないでなければ送信できない。(セキュリティ面を考慮すれば当然の措置とも言えるが・・・)

ubuntuのwakeonlanコマンド

仕様

こんなやつ。

WAKEONLAN(1)                                                                                 User Contributed Perl Documentation                                                                                WAKEONLAN(1)

NAME
       wakeonlan - Perl script to wake up computers

SYNOPSIS
       wakeonlan [-h] [-v] [-i IP_address] [-p port] [-f file] [[hardware_address] ...]

DESCRIPTION
       This script sends 'magic packets' to wake-on-lan enabled ethernet adapters and motherboards, in order to switch on the called PC. Be sure to connect the NIC with the motherboard if neccesary, and enable the WOL
       function in the BIOS.

       The 'magic packet' consists of 6 times 0xFF followed by 16 times the hardware address of the NIC. This sequence can be encapsulated in any kind of packet. This script uses UDP packets.

OPTIONS
       -h  Displays the help information.

       -v  Displays the script version.

       -i ip_address
           Destination IP address. Unless you have static ARP tables you should use some kind of broadcast address (the broadcast address of the network where the computer resides or the limited broadcast address).
           Default: 255.255.255.255 (the limited broadcast address).

       -p port
           Destination port. Default: 9 (the discard port).

       -f file
           File with hardware addresses of wakeable computers. For an example check the file lab001.wol in the examples subdirectory.

EXAMPLES
       Using the limited broadcast address (255.255.255.255):

           $ wakeonlan 01:02:03:04:05:06
           $ wakeonlan 01:02:03:04:05:06 01:02:03:04:05:07

       Using a subnet broadcast address:

           $ wakeonlan -i 192.168.1.255 01:02:03:04:05:06

       Using another destination port:

           $ wakeonlan -i 192.168.1.255 -p 1234 01:02:03:04:05:06

       Using a file as source of hardware and IP addresses:

           $ wakeonlan -f examples/lab001.wol
           $ wakeonlan -f examples/lab001.wol 01:02:03:04:05:06

AUTHOR
       Jose Pedro Oliveira <jpo@di.uminho.pt> maintaining and expanding original work done by Ico Doornekamp <ico@edd.dhs.org>.

COPYRIGHT
       Copyright (c) 2000-2005 Jose Pedro Oliveira.

       This is free software.  You may modify it and distribute it under Perl's Artistic Licence.  Modified versions must be clearly indicated.

SEE ALSO
       For more information regarding this script and Wakeonlan technology just check the following address http://gsd.di.uminho.pt/jpo/software/wakeonlan/.

perl v5.14.2                                                                                             2012-04-30                                                                                             WAKEONLAN(1)

MACアドレスが12:34:56:78:9A:BCの場合の例は以下の通り。

$ wakeonlan 12:34:56:78:9A:BC
Sending magic packet to 255.255.255.255:9 with 12:34:56:78:9A:BC

npm のwakeonlan

npm でもwake on lan を送信できるパッケージがいくつかある。

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4