{"id":27155445,"url":"https://github.com/ymps3502/wireguard-wol","last_synced_at":"2026-05-17T17:01:10.577Z","repository":{"id":286441347,"uuid":"961412176","full_name":"ymps3502/wireguard-wol","owner":"ymps3502","description":"A router-based solution to wake devices via WOL when WireGuard traffic is detected on specific port","archived":false,"fork":false,"pushed_at":"2025-04-06T14:10:09.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-09T05:08:54.990Z","etag":null,"topics":["auto-wakeup","networking","router","shell-script","unraid","wake-on-lan","wireguard"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ymps3502.png","metadata":{"files":{"readme":"README-zh.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-06T13:22:06.000Z","updated_at":"2025-04-06T14:10:12.000Z","dependencies_parsed_at":"2025-04-06T14:43:38.372Z","dependency_job_id":null,"html_url":"https://github.com/ymps3502/wireguard-wol","commit_stats":null,"previous_names":["ymps3502/wireguard-wol"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ymps3502/wireguard-wol","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymps3502%2Fwireguard-wol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymps3502%2Fwireguard-wol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymps3502%2Fwireguard-wol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymps3502%2Fwireguard-wol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ymps3502","download_url":"https://codeload.github.com/ymps3502/wireguard-wol/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ymps3502%2Fwireguard-wol/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278679470,"owners_count":26027087,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auto-wakeup","networking","router","shell-script","unraid","wake-on-lan","wireguard"],"created_at":"2025-04-08T19:40:29.536Z","updated_at":"2025-10-06T21:05:53.429Z","avatar_url":"https://github.com/ymps3502.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WireGuard 自動喚醒方案\n\n## 概述\n此專案實現了一個自動喚醒方案，適用於支援特定指令的路由器。當外部網絡發起 WireGuard 連線請求（預設端口 51820）時，路由器會檢測流量並發送 WOL（Wake-on-LAN）封包喚醒目標設備（例如 Unraid 伺服器）。\n\n## 環境需求\n- **路由器**：需支援 SSH 並具備以下指令：\n  - `netstat-nat`：用於檢測 WireGuard 流量。\n  - `ether-wake`：用於發送 WOL 封包。\n  - `logger`：用於記錄日誌（可選，若無則需修改腳本）。\n  - `cru`：用於設置定時任務。\n- **目標設備**：支援 WOL 的設備（例如 Unraid 伺服器）。\n- **WireGuard 端口**：預設為 51820（可根據實際情況修改）。\n\n## 檔案結構\n- `wol.sh`：發送 WOL 封包的腳本。\n- `check-wireguard.sh`：檢測 WireGuard 流量並觸發 WOL 的腳本。\n- `README.md`：說明文件。\n\n## 建置方式\n\n### 1. 啟用 SSH 並連接到路由器\n1. 進入路由器 Web 介面，啟用 SSH 功能（通常在 **Administration \u003e System** 中）。\n2. 使用 SSH 客戶端連接到路由器：\n    ```ssh\n    ssh username@routerIP\n    ```\n\n### 2. 設置 WireGuard 端口轉發\n在路由器 Web 介面中，設置 NAT 轉發，將外部 51820 端口（UDP）轉發到目標設備（例如 `192.168.1.123:51820`）。\n\n### 3. 確認必要指令可用\n檢查路由器是否支援以下指令：\n```sh\nwhich netstat-nat\nwhich ether-wake\nwhich logger\nwhich cru\n```\n如果缺少任一指令，需考慮更換固件（例如刷 OpenWrt）或使用其他設備。\n\n### 4. 複製腳本到路由器\n1. 將 `wol.sh` 和 `check-wireguard.sh` 複製到 `/jffs/scripts/` 目錄：\n    ```sh\n    echo -e '#!/bin/sh\\nMAC=\"[your mac address]\"\\n/usr/bin/ether-wake -b -i br0 $MAC' \u003e /jffs/scripts/wol.sh\n    echo -e '#!/bin/sh\\n# 檢查 netstat-nat 中是否有 WireGuard 流量\\nif netstat-nat | grep -q \"51820\"; then\\n    /jffs/scripts/wol.sh\\n    logger -t \"WireGuard-WOL\" \"檢測到流量，發送 WOL 封包\"\\nfi' \u003e /jffs/scripts/check-wireguard.sh\n    ```\n    - 將 `[your mac address]` 替換為實際 MAC 地址（例如 `00:11:22:33:44:55`）。\n    - 如果網絡接口不是 `br0`，需調整 `wol.sh` 中的 `-i br0`（例如 `-i eth0`）。\n2. 設置腳本權限：\n    ```sh\n    chmod +x /jffs/scripts/wol.sh\n    chmod +x /jffs/scripts/check-wireguard.sh\n    ```\n\n### 5. 設置定時任務\n1. 使用 `cru` 設置定時任務，每分鐘檢查 WireGuard 流量：\n    ```sh\n    cru a CheckWireGuard \"* * * * * /jffs/scripts/check-wireguard.sh\"\n    ```\n2. 檢查定時任務：\n    ```sh\n    cru l\n    ```\n\n\n### 6. 測試自動喚醒\n1. 讓目標設備進入休眠\n2. 從外部網絡連接到 WireGuard。\n3. 等待一分鐘，檢查目標設備是否被喚醒。\n4. 檢查日誌：\n    ```sh\n    cat /jffs/syslog.log | grep \"WireGuard-WOL\"\n    ```\n\n\n## 限制與改進\n- **延遲**：定時任務每分鐘檢查一次，可能有最多 60 秒的延遲。\n- **固件限制**：如果路由器不支援 `netstat-nat` 或其他必要指令，可考慮：\n- 使用其他設備（例如 Raspberry Pi）監控流量。\n- 刷 OpenWrt，提供完整的流量監控工具（例如 `tcpdump`）。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymps3502%2Fwireguard-wol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fymps3502%2Fwireguard-wol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fymps3502%2Fwireguard-wol/lists"}