几乎所有 Ubuntu 配置 WOL 的指南都是错的
众所周知 Ubuntu 通常使用 netplan 作为网卡配置前端,所有的修改应该通过 /etc/netplan/xxxx.yaml
实现!!!
所以不应该编辑 /etc/network/interfaces 或者乱写什么 systemd 配置,反正不会被保存
所以涉及下列操作的教程都是错的:
- 写任何启动脚本运行
ethtool -s %i wol g
参考配置 sudo nano /etc/netplan/50-cloud-init.yaml
:
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
enp5s0:
dhcp4: true
wakeonlan: true # <--- 要点在这里啊
version: 2
编辑后使用 sudo netplan try
测试,没有问题回车保存
这个功能是防止你乱改以后连不上服务器的,超时没有确认就会自动回撤配置并应用,只有修改好后确认能连上才会保存
然后通过 sudo ethtool <>
检查 WOL 是否开启:
xiwu@hana:~$ sudo ethtool enp5s0
Settings for enp5s0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: Yes
Link partner advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Auto-negotiation: on
master-slave cfg: preferred slave
master-slave status: slave
Port: Twisted Pair
PHYAD: 0
Transceiver: external
MDI-X: Unknown
Supports Wake-on: pumbg
Wake-on: g # <--- 此处为 g 说明开启,d 是支持但未开启,其他的全是失败自行查询
Link detected: yes