Skip to content
Tenvo AI · TRỰC TIẾP · v0.16.4 · TLS · Chứng chỉ cho từng thiết bị · AGPL-3.0 · MIỄN PHÍ · 30 THIẾT BỊ · HẠ TẦNG TỰ LƯU TRỮ · BYO API KEY · MCP CHO CLAUDE & CURSOR
Quay lại BlogTutorial

Wake on LAN cho truy cập từ xa: thiết lập & sửa lỗi

Tenvo Editorial Team8 phút đọc
Wake on LAN cho truy cập từ xa: thiết lập & sửa lỗi

Bạn sẵn sàng truy cập máy tính từ xa và phát hiện máy đang ngủ hoặc tắt. Wake‑on‑LAN là giải pháp — khi nó hoạt động. Hướng dẫn này nêu các bước chính xác trong BIOS, hệ điều hành, mạng và router để làm cho Wake‑on‑LAN (WoL) đáng tin cậy cho truy cập từ xa, cùng các cách an toàn để đánh thức máy qua Internet.

You're ready to remote into a machine and discover it's asleep or powered off. 'Remote desktop wake on lan' is the fix — when it works. This guide walks through the precise BIOS, OS, network and router steps to make Wake‑on‑LAN (WoL) reliable for remote desktop use, plus safe ways to wake machines over the internet.

How Wake‑on‑LAN actually works

Wake‑on‑LAN uses a 'magic packet' sent to the target machine's network interface. The packet is a 6‑byte 0xFF header followed by 16 copies of the target MAC address. The NIC watches for that pattern while the host is in a low‑power sleep state (S3) or sometimes in soft‑off (S5) depending on BIOS and hardware.

Two important network facts:

  • On a LAN the packet is typically a broadcast (e.g., 255.255.255.255 or subnet broadcast like 192.168.1.255).
  • Across the Internet you usually need a router trick (directed broadcast), a VPN into the LAN, or an always‑on relay on the same LAN to forward the magic packet.

Prepare the host: BIOS/UEFI and OS settings

Before you try any network work, confirm the hardware and OS are configured to allow waking.

BIOS / UEFI

  • Boot into BIOS/UEFI (common keys: F2, DEL, F12) and look for 'Wake on LAN', 'Power on by PCI‑E', or 'Wake on PME'. Enable it. On some systems it's under Advanced → Power Management.
  • Check whether WoL is allowed from S3 (sleep) and from S5 (shutdown). Many consumer boards only support S3; some server boards support S5.

Windows 10 / Windows 11

  • Device Manager → Network adapters → select NIC → Properties.
  • Under Power Management: check 'Allow this device to wake the computer' and optionally uncheck 'Allow the computer to turn off this device to save power' if you see problems.
  • Under Advanced: enable 'Wake on Magic Packet' (name can vary by driver) and disable any powersaving that blocks wake.
  • Turn off Fast Startup (Control Panel → Power Options → Choose what the power buttons do → Change settings that are currently unavailable → uncheck 'Turn on fast startup'). Fast startup uses hybrid hibernation and can break WoL.
  • Useful commands: run in an elevated prompt to inspect wake capabilities:
powercfg -devicequery wake_armed
powercfg -a

powercfg -devicequery wake_armed shows devices allowed to wake the system. powercfg -a shows available sleep states (S3 vs S4/S5). If S3 isn't listed, the NIC can't watch for magic packets.

Ubuntu / Debian / other Linux (example: Ubuntu 22.04)

  • Install ethtool (sudo apt install ethtool).
  • Check current WoL state:
    sudo ethtool eth0 | grep -i wake
    The line should say Wake-on: g (magic packet).
  • Enable WoL immediately:
    sudo ethtool -s eth0 wol g
  • To persist the setting, add a systemd unit or configure your network manager. Example systemd unit:
[Unit]
Description=Enable Wake-on-LAN for eth0
After=network.target

[Service]
Type=oneshot
ExecStart=/sbin/ethtool -s eth0 wol g

[Install]
WantedBy=multi-user.target

Replace eth0 with your interface name (ip link show). If the NIC reports other letters (p, u, d), see ethtool docs; you want the 'g' flag.

macOS (example: macOS 13 Ventura)

  • Apple calls it 'Wake for network access' (Energy Saver on older macOS, System Settings → Battery → Options on newer macOS builds). Check that setting for laptops and desktops.
  • Command line:
    sudo pmset -a womp 1
    'womp' enables Wake on Magic Packet. macOS also uses Bonjour Sleep Proxy for Apple devices which can allow wake-on-demand for Macs advertising services.

Wireless clients

WoL over Wi‑Fi (WoWLAN) is limited. Many wireless NICs and drivers do not support wake from a powered‑off state, and support varies by OS and hardware. If possible, prefer wired Ethernet for reliable WoL.

Send the magic packet: tools and methods

Once the host is able to wake, you need a way to send the magic packet from wherever you are.

  • Local LAN: use a phone app or PC tool such as wakeonlan (Linux), WakeMeOnLan (NirSoft, Windows), or mobile apps available on Android/iOS. Example:
    sudo apt install wakeonlan
    wakeonlan 00:11:22:33:44:55
  • From a machine on the same LAN (recommended): a small always‑on device (Raspberry Pi, NAS) can receive remote commands (SSH, HTTP) and send the local magic packet. This avoids router broadcast issues.
  • Over the internet: three common patterns follow; each has pros and cons.

Option A — Router directed broadcast (fragile)

Some routers allow forwarding UDP port 9 (or 7) to the LAN broadcast address (e.g., 192.168.1.255). That sends the magic packet as a broadcast so the sleeping NIC sees it. Caveats:

  • Many consumer and enterprise routers block directed broadcasts by default for security reasons.
  • You expose a UDP port to the internet — attackers can attempt to abuse it. If you use this route, restrict the source IPs or use a high random port and strong firewall rules.

Option B — VPN into the LAN (recommended for security)

Connect your remote device to the LAN via VPN (OpenVPN, WireGuard). Once the VPN puts your client on the same subnet (or your router can route to the subnet), send the magic packet as if you were local. This avoids opening ports to the internet and is compatible with our guide at remote-desktop-without-port-forwarding.

Option C — Always‑on relay on the LAN

Run a tiny relay (a Raspberry Pi, a low‑power PC, or an always‑on NAS) that accepts an authenticated request over the internet and sends the magic packet locally. This is a common pattern for offices where a Pi runs an HTTPS endpoint to trigger wake. Protect it with SSH keys or HTTPS with a long random token.

Khi nó đã được đánh thức: truy cập

Một số bộ phần mềm đóng gói một trình kích hoạt đánh thức vào cơ sở hạ tầng của họ hoặc vào một thiết bị gateway ghép đôi trên LAN — cùng mô hình Option C, với agent của họ ở giữa thay vì Pi của bạn. Dù sao thì gói magic chỉ là một nửa công việc: máy đã bật, và bạn vẫn cần một cách để vào. Nửa đó đáng để không tự xây dựng. Một relay được quản lý có thể tiếp cận máy đã được đánh thức mà không cần mở rộng đường hầm VPN, không cần chuyển tiếp cổng, hoặc một hộp gateway của riêng bạn để phải vá — xem so sánh bản dựng được quản lý với TeamViewer.

Practical example: Wake a Windows PC from the internet using a Raspberry Pi and WireGuard

High level steps:

  1. Reserve a static DHCP lease for the target PC by MAC (so you know the subnet).
  2. Set up a Raspberry Pi on the LAN with a small script to call wakeonlan.
  3. Install WireGuard on the Pi and your remote client. When connected, your remote client can SSH into the Pi or call its local HTTP endpoint to send the magic packet.

Example Pi script (install wakeonlan via apt):

#!/bin/bash
# /usr/local/bin/send-wol.sh
MAC="$1"
if [ -z "$MAC" ]; then
  echo "Usage: send-wol.sh "
  exit 1
fi
/usr/bin/wakeonlan "$MAC"

Make the script executable and call it from an authenticated interface (SSH, systemd socket, or a minimal HTTPS endpoint). That way you don't expose UDP 9 to the world and the Pi can reach the LAN broadcast address locally.

Troubleshooting checklist

If WoL doesn't work, step through this checklist:

  • BIOS: Is Wake‑on‑LAN (or equivalent) enabled? Are S3/S5 wake options available?
  • NIC reports Wake‑on: g (use ethtool on Linux).
  • Windows: 'Allow this device to wake the computer' is checked; Fast Startup is disabled.
  • The host actually has power: look for the NIC LED that often stays lit in sleep states.
  • Magic packet sender: can it reach the target subnet? If sending across subnets, does the router permit directed broadcast?
  • If using wireless, test with wired Ethernet to isolate driver limitations.
  • Check MAC address: a wrong MAC or wrong formatting will fail. Use colon format 00:11:22:33:44:55 with most tools.

Security considerations and recommended practices

Opening UDP 9 to the internet is the weakest option — it exposes a port and offers little authentication. Prefer one of these safer patterns:

  • Kết nối VPN vào LAN (WireGuard/OpenVPN) và gửi gói magic trong nội bộ.
  • Sử dụng một relay có xác thực (SSH hoặc HTTPS) trên Pi hoặc NAS bên trong LAN, relay đó chấp nhận các yêu cầu đã được xác thực và gửi gói magic.
  • Giữ trình kích hoạt đánh thức nhỏ nhất có thể — một endpoint chỉ làm mỗi việc gửi một gói magic — và chạy phiên điều khiển từ xa qua một relay được quản lý thay vì mở rộng đường hầm bạn vừa tạo.

For more on securing remote access, see our articles on remote desktop security and why avoiding open ports is usually smarter: remote desktop without port forwarding.

When WoL won't help

Wake‑on‑LAN does not help if the machine is physically unplugged, the PSU has no standby 5V line to the NIC, or the motherboard/NIC do not support WoL from the desired power state. Also, hibernation (S4) and full shutdown (S5) behavior varies by firmware and OS — test your exact shutdown path.

Final notes and recommended setup

For reliable remote desktop wake on lan, follow this minimal secure recipe:

  1. Bật WoL trong BIOS/UEFI và driver NIC (xác nhận 'Wake-on: g').
  2. Ưu tiên Ethernet có dây khi có thể; kiểm tra việc đánh thức cục bộ trước.
  3. Sử dụng VPN hoặc một relay xác thực luôn‑bật trên LAN để gửi gói magic từ các vị trí từ xa — phải có thứ gì đó bên trong mạng con thực hiện việc đó.
  4. Chạy phiên điều khiển từ xa qua relay được quản lý thay vì mở rộng đường hầm đó: việc đánh thức máy là công việc của LAN, còn việc tiếp cận nó thì không.
  5. Tránh để các broadcast UDP lộ ra internet trừ khi bạn không còn lựa chọn khác và bạn khóa cổng đó thật chặt.

WoL đánh thức máy; việc truy cập nó sau đó là một vấn đề riêng — và vấn đề đó bạn không phải tự xây dựng. Hãy để bất cứ thứ gì nằm trong LAN gửi gói magic, rồi chạy phiên làm việc qua Tenvo và relay được quản lý của nó: không cần mở rộng VPN, không cần chuyển tiếp cổng, không cần gateway riêng để vá. Free là $0, Lite $2.99/tháng, Pro $7.99/tháng — xem những gì mỗi gói bao gồm. Tự‑lưu‑trữ relay là một lựa chọn thực sự (sản phẩm theo AGPL-3.0) và là lựa chọn đúng khi một yêu cầu nêu rõ: quy định tuân thủ cấm hạ tầng bên thứ ba, mạng bị cô lập, cư trú dữ liệu. Khi không có yêu cầu nào như vậy, relay được quản lý thắng về tổng chi phí — trực ứng cứu, vá lỗi, quản lý khóa, gia hạn chứng chỉ, một vùng không có dự phòng. Hướng dẫn tự lưu trữ remote desktop của chúng tôi có đầy đủ chi tiết.

Got everything set up but still stuck? Revisit BIOS sleep state support and the NIC power LED, double‑check the MAC, and run a local wake test before adding router complexity. Once working, you’ll save time and avoid the most common remote‑support headache: 'The computer’s off.'

Nhận Tenvo

Sẵn sàng tự trải nghiệm?

Miễn phí cho 30 thiết bị, không cần thẻ tín dụng. Kết nối và hoạt động trong hai phút.