如何配置网络唤醒(WOL)?

RHEL-Like

1 基础知识

1.1 WOL基本概念

– 网络唤醒英文全称为“Wake-On-LAN”可缩写为“WOL”
– WOL是一种电源管理功能
– WOL允许设备通过活动的网络被唤醒
注:网络唤醒标准由IBM提出

1.2 WOL的作用

– 便于网络管理员进行文件升级
– 便于网络管理员资源跟踪
– 便于网络管理员设备清点等

1.3 WOL的工作原理

– 执行唤醒的设备向被唤醒的设备发送特殊格式的数据包
– 被唤醒的设备受到特殊的数据包即进行开机操作
注:
– 网络唤醒的数据包由AMD公司的MagicPacket套件生成,称为“Magic Packet”,中文称魔术包
– “Magic Packet”格式非世界标准,但受到很多网卡制造商支持

2 最佳实践

2.1 环境信息

执行唤醒的服务器,
Host Name = client.cmdschool.org
OS = CentOS 6.8 x86_64
IP Addresses = any

被唤醒的服务器,
Host Name = server.cmdschool.org
OS = CentOS 6.8 x86_64
IP Addresses = 10.168.0.250

2.2 配置被唤醒的服务器

In Server,

2.2.1 开启主板的唤醒功能

通过重启服务器按下快捷键(每种BIOS有所不同,一般是DEL、ESC、F1、F2、F3、F10)进入BIOS配置,
【Power Management Setup】 –> 【Power On by Onborad Lan】
选择【Enable】
按下【F10】保存
重启重新进入系统
如果是Linux系统,可使用如下命令检查,

ethtool eth0

可见如下显示,

Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Link partner advertised link modes:  10baseT/Half 10baseT/Full
                                             100baseT/Half 100baseT/Full
        Link partner advertised pause frame use: No
        Link partner advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: g
        Current message level: 0x00000033 (51)
                               drv probe ifdown ifup
        Link detected: yes

注:“Supports Wake-on”与“Wake-on”值为“g”则网络唤醒可用

2.2.2 获取硬件地址

ifconfig

可见如下显示,

eth1      Link encap:Ethernet  HWaddr 00:07:E8:A5:F2:5B
          inet addr:10.168.0.250  Bcast:10.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::207:e9ff:feb5:f25a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:103565 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1988540 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6780372 (6.4 MiB)  TX bytes:413348473 (394.1 MiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:16978 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16978 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:18910295 (18.0 MiB)  TX bytes:18910295 (18.0 MiB)

注:可以确定被唤醒的网卡硬件地址为“00:07:E8:A5:F2:5B”

2.3 配置执行唤醒的服务器

In Client,

2.3.1 安装所需的软件包

In Client,

yum install -y wol

另外,由于CentOS 6.x的源已经过期,你可能需要手动设置源,

如何设置CentOS 6.x的yum源?


另外,你可能会找不到以上安装包,你需要先配置epel源,

yum install -y epel-release

2.3.2 获取命令行的帮助

wol --help

可见如下显示,

Usage: wol [OPTION] ... MAC-ADDRESS ...
Wake On LAN client - wakes up magic packet compliant machines.

    --help          display this help and exit
-V, --version       output version information and exit
-v, --verbose       verbose output
-w, --wait=NUM      wait NUM millisecs after sending
-h, --host=HOST     broadcast to this IP address or hostname
-i, --ipaddr=HOST   same as --host
-p, --port=NUM      broadcast to this UDP port
-f, --file=FILE     read addresses from file FILE ("-" reads from stdin)
    --passwd[=PASS] send SecureON password PASS (if no PASS is given, you
                    will be prompted for the password)

Each MAC-ADDRESS is written as x:x:x:x:x:x, where x is a hexadecimal number
between 0 and ff which represents one byte of the address, which is in
network byte order (big endian).

PASS is written as x-x-x-x-x-x, where x is a hexadecimal number between 0
and ff which represents one byte of the password.

Report bugs to 

2.3.3 执行唤醒服务器命令

wol 00:07:E8:A5:F2:5B

执行唤醒后,可使用如下命令监视服务器启动,

ping 10.168.0.250

参阅文档
===================
https://baike.baidu.com/item/wake-on-LAN/8971070?fr=aladdin

https://www.server-world.info/en/note?os=CentOS_6&p=wakeonlan

没有评论

发表回复

RHEL-Like
如何配置rsyncd服务?

1 前言 一个问题,一篇文章,一出故事。 由于笔者想实现文件通过rsync自动传输,但是又不想使用o …

RHEL-Like
如何用pam_google_authenticator认证模块实现SSH 2FA?

1 前言 一个问题,一篇文章,一出故事。 笔者想开启2FA以便增强SSH服务的安全性,于是便整理此文 …

RHEL-Like
如何升级RHEL clamav杀毒?

1 前言 一个问题,一篇文章,一出故事。 笔者需要卸载旧的病毒软件,然后更新rpm包的病毒软件,于是 …