Neurohazard
暮雲煙月,皓首窮經;森羅萬象,如是我聞。

【网络唤醒】Wake On LAN/WLAN 指南

wpadmin~June 23, 2018 /System Management

Wake on LAN

Contents

Wake on LAN Client

Android

WolOn – Wake on LAN
(Google Play)

极致工具箱
http://sj.qq.com/myapp/detail.htm?apkName=com.easyapps.txtoolbox

Linux

etherwake # (root) tcp
wakeonlan # udp

Python

一个 python 的 Wake on LAN 脚本

# !/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName:      wol.py
# Author:        binss
# Create:        2017-06-04 22:32:48
# Description:   Ref: https://github.com/bentasker/Wake-On-Lan-Python
#

import socket
import struct
import time


MAC = "60-6D-C4-C6-30-48"
BROADCAST = "192.168.1.255"


def main():
    if len(MAC) != 17:
        raise ValueError("MAC address should be set as form 'XX-XX-XX-XX-XX-XX'")
    mac_address = MAC.replace("-", '')
    data = ''.join(['FFFFFFFFFFFF', mac_address * 20])
    send_data = b''

    # Split up the hex values and pack.
    for i in range(0, len(data), 2):
        send_data = b''.join([send_data, struct.pack('B', int(data[i: i + 2], 16))])

    # Broadcast
    try:
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
        sock.sendto(send_data, (BROADCAST, 7))
        time.sleep(1)
        sock.sendto(send_data, (BROADCAST, 7))
        time.sleep(1)
        sock.sendto(send_data, (BROADCAST, 7))
        print("Done")
    except Exception as e:
        print(e)


if __name__ == '__main__':
    main()

参考资料

网络唤醒全攻略(Wake On LAN)
https://zhuanlan.zhihu.com/p/29100706

设置网络唤醒电脑(WAKE ON LAN, WOL)
https://blog.csdn.net/xinluke/article/details/51169393

判断主机是否支持远程开机?
http://service.oray.com/question/1331.html

WOL远程唤醒
http://service.oray.com/question/3267.html

Debian Wiki – Wake on LAN
https://wiki.debian.org/WakeOnLan

通过WIFI远程唤醒(Wake-on-WLAN) Windows 10
https://www.binss.me/blog/wake-windows-10-laptop-by-WLAN/

如何远程开启你的电脑:WoL的原理和陷阱
https://zhuanlan.zhihu.com/p/28859620

Shut down, sleep, or hibernate your PC
https://support.microsoft.com/en-gb/help/13770/windows-shut-down-sleep-hibernate-your-pc

Internet or WiFi gets disconnected after Sleep in Windows 10/8
link

Windows 10: prevent sleep mode from disconnecting wifi when copying files?
link

一些坑

Wake on WLAN

如果你想使用 Wake on WLAN
Windows 环境下,部分机型 在 (a. BIOS 开启 WOL b.网卡驱动配置好电源管理选项 c.系统电源选项禁止睡眠 )时,当进入低耗电状态(睡眠、休眠、关机)时, WLAN 会自动断开,因而无法收到唤醒包。

Leave a Reply

Your email address will not be published. Required fields are marked *