6
wake on lan – 网络唤醒电脑
source link: https://xmetal.cc/?p=2091
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
1. 主板上开启
这里使用的是微星主板
- 高级–整合周边设备–网卡ROM启动,设置为允许
- 高级–电源管理设置–Erp ,设置为禁止
- 高级–唤醒事件设置–PCIE设备唤醒,设置为允许
2 检查主机板块和网卡是否支持Wol
检查主板是否支持
sudo apt install ethtool -y (-y 参数是如果出现询问 默认 y)
sudo ethtool eth40ss (eth40ss 指你的网卡可以用 ip a 或者ifconfig 查看)
如果出现一下信息, 则通过
Supports Wake-on: pumbg
Wake-on: g
如果没有则需要开启
sudo ethtool –change enp4s0 wol g
3. ubuntu 20.04设置
which ethtool # 查看命令源 我的是/usr/sbin/ethtool
- 设置开机启动启动 wol 服务,新建服务
sudo vim /etc/systemd/system/wol.service
编辑内容如下
[Unit]
Description=Configure Wake On Lan
[Service]
Type=oneshot
ExecStart=/sbin/ethtool --change enp43s0 wol g
[Install]
WantedBy=basic.target
#To enable it you can do this:
sudo systemctl daemon-reload
sudo systemctl enable wol.service
sudo systemctl start wol.service
#查看设置状态
systemctl status wol
2.使用netplan 永久自动开发方法
需要添加mac 地址
1
network:
2
version: 2
3
renderer: networkd
4
ethernets:
5
enp2s0:
6
match:
7
macaddress: 50:e5:49:b3:fc:97
8
dhcp4: true
9
wakeonlan: true
4. 关闭服务器, 本地使用 命令 启动服务器
唤起远程服务端的客户端上需要安装
Command-line tools
unbuntu 可以安装
sudo apt install wakeonlan
wakeonlan mac地址 #唤醒电脑
mac python脚本 wol.py
01
#!/usr/bin/env python
02
03
import socket
04
import sys
05
06
if len(sys.argv) < 3:
07
print "Usage: wakeonlan.py <ADR> <MAC> (example: 192.168.1.255 00:11:22:33:44:55)"
08
sys.exit(1)
09
10
mac = sys.argv[2]
11
data = ''.join(['FF' * 6, mac.replace(':', '') * 16])
12
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
13
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
14
sock.sendto(data.decode("hex"), (sys.argv[1], 9))
1
python wol.py 192.168.1.255 00:11:22:33:44:55
在路由上安装
1
opkg install etherwake
2
3
如果你的路由是主路由,那么要设置广播的网关段,而小米的网络段是192.168.31.255:
4
/usr/bin/etherwake -D -i 'lan' "D8:BB:C1:4F:E5:12" 2>&1
5
6
如果你的路由是旁路由
7
wakeonlan -i mac地址
8
9
这样通过zerotier远程连接路由器SSH,然后通过命令就可以开启局域网中的指定电脑。
Post navigation
Leave a Reply Cancel reply
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
Website
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK