Translation(s): English - Español - Français - Italiano - Русский


Wake On LAN

Немного заметок об особенностях работы Wake On LAN (WOL) в операционной системе Debian.

Аппаратная часть

Ваш первый шаг к загрузке компьютера через сеть - убедиться, что ваша Ethernet-карта и материнская плата поддерживают какой-либо тип функции Wake On LAN. В особенности карты 3Com's маркировки -NM (non managed) не поддерживают WOL, тогда как карты маркировки -M (managed) поддерживают.

Есть две основные системы. Старый способ заключается в использовании 3-пинового коннектора Wake On LAN между вашей Ethernet-картой и материнской платой. Оба гнезда(англ.версия - "headers") обычно именуются 'wol'. Более новая система использует Wake On LAN pin на PCI-шине, что устраняет необходимость в кабеле. Некоторые материнские платы поддерживают оба варианта и только предоставляют гнездо для обратной совместимости с Ethernet-картами, не поддерживающими PCI pin.

Более новые материнские платы с встроенными сетевыми картами поддерживают Wake On LAN без необходимости каких-либо выводов / кабелей.

Прошивка / BIOS

В хорошем BIOS в управлении питанием вы найдёте ясную, интуитивно понятную опцию "Wake On LAN". К сожалению, моя система не была столь ясной и имела несколько возможных вариантов. один казался работающим всегда, остальные - временами. Я строил по информации заимствованной у Mark Ivey, т.к. У меня тоже есть Shuttle XPC SK41G и я успешно использую опцию "PowerOn by PCI Card".1

Софт

Настройка интерфейса

stretch

Добавьте этот файл:

$ cat /etc/network/interfaces.d/eth0
auto eth0
iface eth0 inet dhcp
        ethernet-wol g

перезагрузитесь. Проверьте работу:

$ sudo ethtool eth0

Settings for eth0:
        Supported ports: [ MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 1
        Transceiver: external
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: g
        Link detected: yes

Директива Wake-on: g означает, что всё работает.

Squeeze

Для Squeeze ethtool параметры могут быть установлены непосредственно из /etc/network/interfaces. Результат выше может быть достигнут так:

iface eth0 inet dhcp
        ethernet-wol g

Скрипт /etc/network/if-up.d/ethtool будет заботиться о вызове ethtool по ifup. Читайте /usr/share/doc/ethtool/README.Debian для более полной информации.

Дальше можете выключить систему и приготовить остальные системы, чтобы разбудить её.

После squeeze

После аппаратной активации Wake On LAN также необходимо активировать его в программном обеспечении. Это делается с использованием программы ethtool, которая говорит интерфейсу отвечать на волшебный пакет (the magic packet). Замените eth0 на имя вашего сетевого интерфейса:

$ su
# aptitude install ethtool
# ethtool -s eth0 wol g

Это можно автоматизировать с помощью записи в /etc/network/interfaces:

iface eth0 inet dhcp
        post-up /sbin/ethtool -s $IFACE wol g
        post-down /sbin/ethtool -s $IFACE wol g

Это запускает ethtool после каждого подъёма интерфейса eth0, а также после его отключения, таким образом WOL должен работать даже в случае, когда сеть отключена некорректно.

Отправка WOL сообщений

Я установил пакет etherwake в контролирующей системе для отправки "Magic Packet" к моему компьютеру для пробуждения. Программа должна быть запущена от имени root для отправки пакета (Я использую sudo для её запуска).

# aptitude install etherwake
# etherwake <mac address>

Также доступен wakeonlan - программа, использующая UDP-пакеты, а TCP, и не требующая прав root для запуска. Она также чуть более гибкая в настройке.

# aptitude install wakeonlan && exit
$ wakeonlan <mac address>

WOL чувствительность

Я нашёл, что не хочу каких-либо Wake On LAN настроек, за исключением Wake on "Magic Packet" (g). Я хочу только включать мою машину тогда, когда я ей это говорю, ни одноадресных (u), широковещательных (b) или многоадресных (m) сообщений.

WOL Persistence

Hardware looks up to spec, you think the BIOS is set right, but it still doesn't work without some tweaking using the software. According to the Wake On Lan client FAQ most Linux drivers disable the WOL feature on boot2, so we need to get it going.

Kernel 2.6

With a 2.6 kernel we're using /etc/modprobe.d. You may be using /etc/modprobe.conf, but if it's not including /etc/modprobe.d you're probably getting told about that each time you boot and some stuff may not be configured properly. I'm using /etc/modprobe.d and I added a file local.conf into the directory. It says:

install 8139too /sbin/modprobe -i 8139too; /sbin/ethtool -s eth0 wol g

ethtool comes from the ethtool package, so you'll need to install that unless your card supports a load option to set WOL. If that's the case I'd make an local.conf file with the appropriate options line, maybe something like:

options 3c59x enable_wol=1

Testing on another machine with a C3905B-TXNM and a 3C905C-TXM that uses the 3c59x module to drive them both I found that ethtool was unable to query them or set the WOL setting, but that the enable_wol=1 setting did work and was required.

While I was messing with these settings, I noticed that both 8139too and 8139cp were loading, but loading just 8139cp alone failed since my chipset isn't new enough so I blacklisted it.

Debugging state with ethtool

After an hour struggling with why my system still didn't work I started throwing in the ethtool query command all over the place to see what the deal was:

# ethtool eth0

ifup

I found that (at least with my 8139too driver on Debian 3.1/Sarge) the install line was working when I'd modprobe 8139too, but ifup also resets the WOL setting, so I added an up line to /etc/network/interfaces under eth0:

iface eth0 inet dhcp
        up /sbin/ethtool -s $IFACE wol g

I kept the ethtool command in /etc/modprobe.d/local.conf in case I boot and ifup isn't executed before shutting down.

Conclusion

Wake On LAN works on Debian and opens some new options up to me.

I can log into my gateway and boot my desktop, grab what I need and then power it back off remotely. I'm using DHCP with MAC-to-IP mappings so I can look in that file on my gateway system to know the MAC address of the system I wish to wake up. If I didn't have that I could keep a text file.

My next feat is to have non-essential systems power-off (not just halt) on a power outage to extend the battery runtime for the essential systems and then use WOL to power the other systems back on after power is restored and the battery has hit some specific charge level. I think some settings with halt or APM or ACPI are not right on those systems. See OffAndOnAgain.


CategoryNetwork | CategorySystemAdministration