如何在 Ubuntu 16.04 中启用网络唤醒 (WOL)

nke*_*kef 33 wakeonlan 16.04

如何在 Ubuntu 16.04 LTS 中启用网络唤醒(WOL)?

loc*_*oop 28

我找到了一种更适合我的方法。至少是一种更清洁的方式。显然 Ubuntu在 Ubuntu 15.04、Ubuntu 16.04 和大概的下一个版本中为systemd改变了暴发户。我对这两个系统都不熟悉,但这对我有用。

我发布这个是因为在谷歌搜索 Ubuntu 16 wol和其他类似的搜索时,我多次遇到这篇文章。这可以帮助其他人。

为了保持 WOL 工作,我必须在每次系统启动时重新启用它。为了避免手动执行此操作,我为此使用了 systemd。这就是我所做的:

  1. 首先,创建文件/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
    
    Run Code Online (Sandbox Code Playgroud)
  2. 在启动时为接口启用此功能,运行以下命令(使用您的接口更改 eth3):

    systemctl enable wol@eth3
    
    Run Code Online (Sandbox Code Playgroud)

    您应该会看到如下内容:

    Created symlink from /etc/systemd/system/multi-user.target.wants/wol@eth3.service to /etc/systemd/system/wol@.service.
    
    Run Code Online (Sandbox Code Playgroud)
  3. 要检查它是否已启用,请运行以下命令(使用您的接口更改 eth3),它应该返回enabled

    systemctl is-enabled wol@eth3
    
    Run Code Online (Sandbox Code Playgroud)
  4. 要对此进行测试,请重新启动并运行(使用您的界面更改 eth3):

    ethtool eth3
    
    Run Code Online (Sandbox Code Playgroud)

    您应该看到一行包含以下内容:

    Wake-on: g
    
    Run Code Online (Sandbox Code Playgroud)

资料来源:


nke*_*kef 20

在Ubuntu 16.04一套WOL_DISABLE=N/etc/default/tlp以避免收到由TLP电源管理禁用WOL。

http://linrunner.de/en/tlp/docs/tlp-configuration.html

添加NETDOWN=no/etc/default/halt防止停机期间关闭网卡供电

/etc/network/interfaces使用静态网络配置时启用 LAN 唤醒。

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface

auto lo
iface lo inet loopback
# The primary network interface

auto eth0
iface eth0 inet static
        address 192.168.0.10
        netmask 255.255.255.0
        gateway 192.168.0.1
        dns-nameservers 192.168.0.1
        up ethtool -s eth0 wol g
Run Code Online (Sandbox Code Playgroud)

在 BIOS 中启用 LAN 唤醒,进入 BIOS 设置并查找名为“Wake up on PCI 事件”、“Wake up on LAN”或类似内容的内容。更改它以启用它。保存您的设置并重新启动。

https://help.ubuntu.com/community/WakeOnLan

警告某些主板/网络控制器不支持冷启动时的 WOL(S5 状态,系统的电源被物理关闭并再次打开)。在这种情况下,必须执行至少一个电源循环(通电、关机)。为了缓解这个问题,可以将 BIOS 配置为在交流电恢复时开机,然后在 Ubuntu 内部安排关机。有关详细信息,请参阅主板手册。


小智 8

在终端中运行以下命令:

sudo ethtool -s {your network interface} wol g 
sudo ethtool {your network interface}
Run Code Online (Sandbox Code Playgroud)

写入第二个命令后,您应该会在 lan唤醒旁边看到一个g

来源


Tom*_*liy 7

如果您使用 NetworkManager,则可以通过以下方式启用 WOL nmcli

nmcli connection show
Run Code Online (Sandbox Code Playgroud)

记住感兴趣的设备的“802-3-ehternet”类型连接的名称。假设其名称为“有线连接 1”。然后适当修改一下:

nmcli connection modify "Wired connection 1" 802-3-ethernet.wake-on-lan magic
Run Code Online (Sandbox Code Playgroud)

要获取其 MAC 地址:

nmcli connection show "Wired connection 1" | grep 802-3-ethernet.mac-address
Run Code Online (Sandbox Code Playgroud)

从现在起,您可以通过命令从同一 LAN 上的另一台计算机将其关闭和打开wakeonlan 1a:2b:3c:4d:5e:6f,其中1a:2b:3c:4d:5e:6f是上一步中 LAN 卡的 MAC 地址。