Linux系统与Windows系统下的网络唤醒

简介:

Wake on Lan with Linux and Windows

Linux系统与Windows系统下的网络唤醒

Motivation

问题起因


I have 3 computers. My laptop a Thinkpad X30, another Thinkpad which acts as server and a desktop computer. I have all my main data on my server and use the files on my laptop and desktop by sshfs and NFS.

我有3台计算机。我的笔记本电脑Thinkpad X30另一个Thinkpad充当服务器还有台桌面用电脑我的最主要的数据存储在服务器中,我使用笔记本电脑或桌面用电脑通过sshfs和NFS来访问它们

 

The only files I don’t store on my server is media files, such as movies and music – these are stored on my desktop. This was the problem – if I was out I couldn’t access my files since my desktop was turned off when I am not home. I need something to turn on my desktop when I wasn’t home.

 媒体文件是我唯一不存储在服务器的文件,诸如电影和音乐——这些都储存在桌面用电脑中。问题是——当我外出时,桌面用电脑处于关闭状态,我是我无法访问所需要的文件的。当我不在家时,我希望能够有某种方式可以远程启动我的桌面用电脑。



 

Wake on Lan

网络唤醒
Wake on Lan (WOL) is a technology to turn on a computer by sending it a specific network package. When a WOL-enabled computer is turned off the network port will stay active and listen for a certain packages and in if it receives such a package it will boot the computer.

网络唤醒(WOL)是一种技术,通过向一台计算机发送一个特定的网络包来启动它。当一个设置为允许网络唤醒的计算机处于关闭状态时其网络端口将保持活跃并里监听了某些特定的包,如果收到则会启动电脑。

Two things are needed:

两个必需条件: 

  • Enable WOL on my Desktop.
  • 设置计算机为允许网络唤醒。
  • Installing a program to send the magical network package on my server.
  • 在服务器上安装一个可以用于发送魔术包(使电脑自动开机的数据包)的软件。

BIOS

BIOS设置
Somewhere in the BIOS there will hopefully be some setting to enable WOL. I didn’t find it in the BIOS of my ASUS PW5 DH motherboard, but it works fine. A good indicator is to check whether the lights around the network cable is turned on or not on the back of the computer when the computer has been shutdown.

我希望可以在BIOS中有某些关于WOL的设置。只是在我的华硕PW5 DH主板BIOS中没有找到,但是它确实是运行着的。一个很好的验证方式,就是当你的计算机关机后,且保持网线插入了网卡接口,且在关机前机器可以顺利上网。如果此时网卡上的指示灯亮着表示支持WOL了。

Enabling WOL in Windows

在Windows系统中设置WOL
It always takes more screenshots to explain anything in Windows, but there is not really any way around it. In Windows I need to go to the network setting and choose my network adapter. After selecting “configure” as in the screenshot:

很多时候如果有截图会更好的说明问题,只是有时候却是无法抓取屏幕的。在Windows系统中打开网络设置,然后再弹出属性窗口。在选取“configure”选项后的截图如下:

译者注:所有的设定没有标准的固定的模式,如果你的计算机无法照做,并不说明你的机器无法设置wol,这里只是提供了一种实现而已。译者本人所管理的计算机中有的可以在主板BIOS上设置实现,而有的用的是此种方式。或许还有其他。

 I selected the fan called “advanced” where I found to settings I need to turn on:

我选取了“advanced(高级)”选项卡,在这里找到了我需要的选项:
Wake from shutdown(从关机状态下唤醒):


Wake up capabilities(唤醒功能):


That’s it. :)很好。

Enabling WOL in Linux

使Linux实现WOL
To enable WOL from Linux the option has to be set before shutting Linux down. First I see what is supported by network driver

WOL需要在未关闭Linux系统时进行设置。首先查看网络驱动支持的内容是什么


 
 
  1. root@bohr:/home/tjansson# ethtool eth1  
  2. Settings for eth1:  
  3.         ...  
  4.         Supports Wake-on: pg  
  5.         Wake-on: d  
  6.         ... 
  7. 译者机器上显示内容为:
  8. Supports Wake-on: pumbg
  9. 	Wake-on: g
So it supports  pg which means (from man ethtool):
pg选项的含义(源自ethtool命令的man手册):
 

 
 
  1. p  Wake on phy activity  
  2. g  Wake on MagicPacket(tm) 

 
 
  1. 在译者的系统中还有三项设置:
  2. u   Wake on unicast messages 
  3. m   Wake on multicast messages 
  4. b   Wake on broadcast messages 
The  g option is the interesting part. So I set the option on the my network driver:
 这个g参数是一个有趣的部分。所有我在网络驱动上设置了这个选项。

 
 
  1. root@bohr:~# ethtool -s eth1 wol g 
but I don’t want to do this every time I shut down the computer, so I will make a script in  /etc/init.d/ named wol.sh containg the lines:
我并不想在每次关机时都重复此设置,所以我将写一个名为wol.sh的脚本放入到/etc/init.d/文件夹中,其内容如下:

 
 
  1. #!/bin/bash  
  2. ethtool -s eth1 wol g 
and make it executable:
并且使之可执行:

 
 
  1. root@bohr:/etc/init.d# chmod +x wol.sh 
and finally tell Linux to execute the script on every runlevel, which I quite a overkill, but it doesn’t really mater – it works:
最后通知所有运行级别均自动运行此脚本,我的特别操作并非废话-操作如下:
 

 
 
  1. root@bohr:/etc/init.d# update-rc.d -f wol.sh defaults 

Now WOL is enabled under Linux as well.

现在WOL在Linux被允许了。

Sending the magical package from Linux

从Linux系统是发送魔术包
The last thing I need to do is to wake the computer after it has been shut down. I do this from my Linux server on the same local network. The only information needed is the hardware adress of network interface on the desktop machine. I can find this by running ifconfig under Linux or some networkgui on Windows on the desktop machine:

最后我要做的是唤醒已经关闭的计算机。我是在服务器上做这件事情的,它与被唤醒机器处于同一局域网中。唯一所需的信息就是被唤醒机器的网卡硬件地址。可以在Linux执行ifconfig命令或在Windows系统中通过网络设置的图形界面进行查看。(译者注:在Windows中运行ipconfig命令查看)


 
 
  1. tjansson@bohr:~$ /sbin/ifconfig  
  2. ...  
  3. eth1      Link encap:Ethernet  HWaddr 00:18:F3:CD:78:A0  
  4. ... 
Now I can start the desktop computer by running wakeonlan from my server:
现在,可以通过在服务器上运行“wakeonlan”命令来唤醒目标机器。

 
 
  1. root@nobel:/home/tjansson# wakeonlan 00:18:F3:CD:78:A0  
  2. Sending magic packet to 255.255.255.255:9 with 00:18:F3:CD:78:A0 
Waking the computer from other OS’s
在其它类型的系统时实现计算机唤醒
In the bottom of the  wikipediaentry on WOL there is a long list of other programs to send the magical network package but I haven’t tried any of these my self.
 在 wikipediaentry on WOL 的底部,有很长的可以发送魔术包的程序列表,只是我没有进行相关的测试。

[翻译完,于2012年04月24日 星期二 09时26分25秒 ]



本文转自tiancong 51CTO博客,原文链接:http://blog.51cto.com/tiancong/842244

相关文章
|
1月前
|
机器学习/深度学习 人工智能 算法
基于Python深度学习的眼疾识别系统实现~人工智能+卷积网络算法
眼疾识别系统,本系统使用Python作为主要开发语言,基于TensorFlow搭建卷积神经网络算法,并收集了4种常见的眼疾图像数据集(白内障、糖尿病性视网膜病变、青光眼和正常眼睛) 再使用通过搭建的算法模型对数据集进行训练得到一个识别精度较高的模型,然后保存为为本地h5格式文件。最后使用Django框架搭建了一个Web网页平台可视化操作界面,实现用户上传一张眼疾图片识别其名称。
104 5
基于Python深度学习的眼疾识别系统实现~人工智能+卷积网络算法
|
4天前
|
机器学习/深度学习 数据可视化 算法
PyTorch生态系统中的连续深度学习:使用Torchdyn实现连续时间神经网络
神经常微分方程(Neural ODEs)是深度学习领域的创新模型,将神经网络的离散变换扩展为连续时间动力系统。本文基于Torchdyn库介绍Neural ODE的实现与训练方法,涵盖数据集构建、模型构建、基于PyTorch Lightning的训练及实验结果可视化等内容。Torchdyn支持多种数值求解算法和高级特性,适用于生成模型、时间序列分析等领域。
126 77
PyTorch生态系统中的连续深度学习:使用Torchdyn实现连续时间神经网络
|
2天前
|
机器学习/深度学习 编解码 测试技术
YOLOv11改进策略【模型轻量化】| 替换骨干网络为 2024轻量化网络MoblieNetV4:移动生态系统的通用模型
YOLOv11改进策略【模型轻量化】| 替换骨干网络为 2024轻量化网络MoblieNetV4:移动生态系统的通用模型
18 8
YOLOv11改进策略【模型轻量化】| 替换骨干网络为 2024轻量化网络MoblieNetV4:移动生态系统的通用模型
|
14天前
|
Linux 网络性能优化 网络安全
Linux(openwrt)下iptables+tc工具实现网络流量限速控制(QoS)
通过以上步骤,您可以在Linux(OpenWrt)系统中使用iptables和tc工具实现网络流量限速控制(QoS)。这种方法灵活且功能强大,可以帮助管理员有效管理网络带宽,确保关键业务的网络性能。希望本文能够为您提供有价值的参考。
62 28
|
11天前
|
网络协议 Unix Linux
深入解析:Linux网络配置工具ifconfig与ip命令的全面对比
虽然 `ifconfig`作为一个经典的网络配置工具,简单易用,但其功能已经不能满足现代网络配置的需求。相比之下,`ip`命令不仅功能全面,而且提供了一致且简洁的语法,适用于各种网络配置场景。因此,在实际使用中,推荐逐步过渡到 `ip`命令,以更好地适应现代网络管理需求。
26 11
|
28天前
|
监控 搜索推荐 开发工具
2025年1月9日更新Windows操作系统个人使用-禁用掉一下一些不必要的服务-关闭占用资源的进程-禁用服务提升系统运行速度-让电脑不再卡顿-优雅草央千澈-长期更新
2025年1月9日更新Windows操作系统个人使用-禁用掉一下一些不必要的服务-关闭占用资源的进程-禁用服务提升系统运行速度-让电脑不再卡顿-优雅草央千澈-长期更新
98 2
2025年1月9日更新Windows操作系统个人使用-禁用掉一下一些不必要的服务-关闭占用资源的进程-禁用服务提升系统运行速度-让电脑不再卡顿-优雅草央千澈-长期更新
|
22天前
|
机器学习/深度学习 监控 算法
基于yolov4深度学习网络的排队人数统计系统matlab仿真,带GUI界面
本项目基于YOLOv4深度学习网络,利用MATLAB 2022a实现排队人数统计的算法仿真。通过先进的计算机视觉技术,系统能自动、准确地检测和统计监控画面中的人数,适用于银行、车站等场景,优化资源分配和服务管理。核心程序包含多个回调函数,用于处理用户输入及界面交互,确保系统的高效运行。仿真结果无水印,操作步骤详见配套视频。
46 18
|
1月前
|
Ubuntu Linux 开发者
Ubuntu20.04搭建嵌入式linux网络加载内核、设备树和根文件系统
使用上述U-Boot命令配置并启动嵌入式设备。如果配置正确,设备将通过TFTP加载内核和设备树,并通过NFS挂载根文件系统。
82 15
|
6月前
|
Ubuntu Linux 虚拟化
安装Windows Linux 子系统的方法:适用于windows 11 版本
本文提供了在Windows 11系统上安装Linux子系统(WSL)的详细步骤,包括启用子系统和虚拟化功能、从Microsoft Store安装Linux发行版、设置WSL默认版本、安装WSL2补丁,以及完成Ubuntu的首次安装设置。
1586 2