1. Linux

网络唤醒-Go编码实现-ROG-Windows设置WOL

0、WOL介绍

0.1、History

In October 1996, Intel and IBM formed the Advanced Manageability Alliance (AMA). In April 1997, this alliance introduced the Wake-on-LAN technology.

0.2、Magic packet

The magic packet is a frame that is most often sent as a broadcast and that contains anywhere within its payload 6 bytes of all 255 (FF FF FF FF FF FF in hexadecimal), followed by sixteen repetitions of the target computer’s 48-bit MAC address, for a total of 102 bytes.

Since the magic packet is only scanned for the string above, and not actually parsed by a full protocol stack, it could be sent as payload of any network- and transport-layer protocol, although it is typically sent as a UDP datagram to port 0 (reserved port number),[6] 7 (Echo Protocol) or 9 (Discard Protocol),[7] or directly over Ethernet as EtherType 0x0842.[8] A connection-oriented transport-layer protocol like TCP is less suited for this task as it requires establishing an active connection before sending user data.

A standard magic packet has the following basic limitations:

  • Requires destination computer MAC address (also may require a SecureOn password)
  • Does not provide a delivery confirmation
  • May not work outside of the local network
  • Requires hardware support of Wake-on-LAN on destination computer
  • Most 802.11 wireless interfaces do not maintain a link in low power states and cannot receive a magic packet

The Wake-on-LAN implementation is designed to be very simple and to be quickly processed by the circuitry present on the network interface card with minimal power requirement. Because Wake-on-LAN operates below the IP protocol layer, IP addresses and DNS names are meaningless and so the MAC address is required.

1、BIOS配置 & WINDOWS配置

这里仅给出ROG主板的设置,其他主板仅供参考。

[主板]BIOS如何设置启用网络唤醒(WOL: Wake On Lan)功能

2、测试

可以使用微信小程序:网络唤醒WakeOnLan,填写对应的MAC地址进行唤醒测试。

 

 

3、编码实现

采用WOL和电子邮件技术实现通过发送邮件到指定邮箱来远程开启内网主机。 代码采用golang编写,可以非常方面的移植到各种架构的设备上如:路由器,安卓手机,PC机等。

https://github.com/bh6aol/go-wol

4、一些问题

问题:将编译完成的可执行程序放到小米路由器3中运行报错:x509: certificate signed by unknown authority

解决方法:将我的Debian中 /etc/ssl 目录复制到小米路由器的 /etc/ssl 下即可。

参考