-
打開主板相關設置
-
創建 systemd 自啟動設置文件
vim /etc/systemd/system/wol@.service
放入以下內容:
[Unit]
Description=Wake-on-LAN for %i
Requires=network.target
After=network.target
[Service]
ExecStart=/sbin/ethtool -s %i wol g
Type=oneshot
[Install]
WantedBy=multi-user.target
- 確定網卡名稱
ip a
由於我的設備只有一個有線網卡,可以看到,網卡名稱是enp2s0
。一般來說,使用有線網卡進行 WoL 的配置。
- 啟用指定網卡的 WoL 自啟動文件
systemctl enable wol@enp2s0
- 啟動
systemctl start wol@enp2s0
- 測試
ethtool enp2s0
可以看到,配置已經生效。重啟后再次嘗試,配置依然生效。
- 后話
Linux 可以使用etherwake
喚醒設備,使用方式:
etherwake -b [被喚醒設備網卡的mac地址] -i [發出喚醒請求的網卡名稱]
也可以使用 wakeonlan
喚醒,使用方式:
wakeonlan [被喚醒設備網卡的mac地址]