iWIN 必須被解散!

Weil Jimmer's BlogWeil Jimmer's Blog


在區域網路中使用 OpenWrt 的 LuCI 介面實現喚醒電腦 Wake on LAN (WOL)

-
更新於 2023-09-17 22:24:56

前言

昨天剛睡醒躺在床上看小說的時候,內心一直有個聲音是:好想開電腦聽音樂喔,但是我卻很懶得爬起床。

想到我應該寫個 Web API 用區網 (Wi-Fi) 就可以啟動音樂播放軟體阿!後來仔細想了想,電腦如果是關機狀態的話,即便寫了,也還是沒有用。

於是才突然想到,可以嘗試看看 Magic Packet 喚醒功能 (Wake-on-LAN) 阿。於是就有了這篇文章,懶惰是促使人進步的動力來源。

原則上這篇文章沒有甚麼技術成分。僅僅是記錄我的操作過程。

設定網卡

這非常簡單設置,基本上就是直接從 Windows 中控制台找到網路介面卡,打勾選項,點確定而已。

設定開啟。

這裡是關機時的網卡速度,正處於關機狀態時,用不到那麼大的頻寬,可以設定成最低,也就是 10 Mbps。

設定允許這個裝置喚醒電腦。

接著重新啟動,到主機板 BIOS 設定允許我現在的網卡喚醒電腦。

設定 OpenWrt

開啟登入 OpenWrt,安裝 WOL 的相關套件。

opkg install etherwake luci-app-wol

重啟 OpenWrt 軟路由,應該會在服務的 tab 下面找到 Wake on LAN。

測試

在關機狀態下,可以從交換器中看到 Port 3 (也就是連接電腦網卡的接口),它此時的速度只有 10M,跟上面所設定的一模一樣。

如果沒有設定 WOL 的話,你關機後,Port Status 會直接顯示成 Down (下線)。

之後就可以將電腦關機,然後直接透過手機連到 OpenWrt 發送 Magic 封包叫醒電腦。

按下發送鍵後,就會看到封包的資料,結構很簡單,類別 0x0842,內容給定 ffffffffffff 之後,再重複目標 MAC 地址十六次。

DA     (6)        | SA     (6)        | Type WOL (2)
3c 52 a1 29 6d 9e | 26 62 d2 e3 a6 83 | 08 42

Sync stream       | Repeat 16 times of MAC
ff ff ff ff ff ff | 3c 52 a1 29 6d 9e 3c 52 a1 29 6d 9e
3c 52 a1 29 6d 9e 3c 52 a1 29 6d 9e 3c 52 a1 29 6d 9e
3c 52 a1 29 6d 9e 3c 52 a1 29 6d 9e 3c 52 a1 29 6d 9e
3c 52 a1 29 6d 9e 3c 52 a1 29 6d 9e 3c 52 a1 29 6d 9e
3c 52 a1 29 6d 9e 3c 52 a1 29 6d 9e 3c 52 a1 29 6d 9e
3c 52 a1 29 6d 9e 3c 52 a1 29 6d 9e 

當網路介面卡收到這「魔法封包」後,電腦就會自己開機,進入 Windows 登入畫面!而此時交換器中 Port 3 的狀態也會恢復成正常的 1000M。

順帶一提,我網卡本身是 2.5 Gbps,但交換器只有支援 1 Gbps,所以上限 1000M 是正常的。

By Weil Jimmer


This entry was posted in Experience, The Internet, Note, OpenWrt By Weil Jimmer.

About Weil Jimmer

avatar

Hi! Everyone! My name is Weil Jimmer. This is my personal blog. I'm a webmaster of this site. I hope the site will be popular. Now, Let's go! Enjoy gaining more knowledge.
More Details About Me : https://weils.net/profile.php

Leave a Reply

Name*:

Email*:

Website:

Privacy:   

Comment*:

Visitor Count

pop
nonenonenone

Note

支持網路中立性.
Support Net Neutrality.

飽暖思淫欲,饑寒起盜心。

支持臺灣實施無條件基本收入

歡迎前來本站。

Words Quiz


Search

Music

Blogging Journey

4257days

since our first blog post.

Republic Of China
The strong do what they can and the weak suffer what they must.

Privacy is your right and ability to be yourself and express yourself without the fear that someone is looking over your shoulder and that you might be punished for being yourself, whatever that may be.

It is quality rather than quantity that matters.

I WANT Internet Freedom.

Reality made most of people lost their childishness.

Justice,Freedom,Knowledge.

Without music life would be a mistake.

Support/Donate

This site also need a little money to maintain operations, not entirely without any cost in the Internet. Your donations will be the best support and power of the site.
MethodBitcoin Address
bitcoin1gtuwCjjVVrNUHPGvW6nsuWGxSwygUv4x
buymeacoffee
Register in linode via invitation link and stay active for three months.Linode

Support The Zeitgeist Movement

The Zeitgeist Movement

The Lie We Live

The Lie We Live

The Questions We Never Ask

The Questions We Never Ask

Man

Man

THE EMPLOYMENT

Man

In The Fall

In The Fall

Facebook is EATING the Internet

Facebook

Categories

Android (7)

Announcement (4)

Arduino (2)

Bash (2)

C (3)

C# (5)

C++ (1)

Experience (51)

Flash (2)

Free (13)

Functions (36)

Games (13)

General (58)

Git (1)

HTML (7)

Java (13)

JS (7)

Mood (24)

NAS (2)

Note (31)

Office (1)

OpenWrt (5)

PHP (9)

Privacy (4)

Product (12)

Python (4)

Software (11)

The Internet (24)

Tools (16)

VB.NET (8)

WebHosting (7)

Wi-Fi (5)

XML (4)