我的思路是通过电脑主板自带的Wake on Lan 功能,目前来说大部分主板都有(我的主板是x99 QD4)。最大的问题是在于配置为S5(shutdown)状态下时网卡需要在关机后处于激活状态,而这里需要系统在启动后将对应的网卡状态设置为对应状态。(因为Ubuntu20.04后网络唤醒重启之后网卡状态设置就会失效。。。不知道为啥)
Option Description p Wake on PHY activity u Wake on unicast messages m Wake on multicast messages b Wake on broadcast messages g Wake on MagicPacket messages
更新网卡状态。由于我们要使用的是MagicPacket信息,因此:
1 2
sudo ethtool --change enp6s0 wol g sudo ethtool enp6s0
○ wakeonlan.service - Enable Wake On Lan Loaded: loaded (/etc/systemd/system/wol.service; enabled; vendor preset: enabled) Active: inactive (dead) since Tue 2024-02-20 23:32:35 +08; 28min ago Main PID: 948 (code=exited, status=0/SUCCESS) CPU: 2ms
Feb 20 23:32:34 Server systemd[1]: Starting Enable Wake On Lan... Feb 20 23:32:35 Server systemd[1]: wol.service: Deactivated successfully. Feb 20 23:32:35 Server systemd[1]: Finished Enable Wake On Lan.