Skip to content

Power Management

Wake offline target PCs remotely using Wake-on-LAN.

Overview

Nefia's power management supports remote wake-up via Wake-on-LAN (WoL). You can wake target PCs that are asleep or powered off through an agent on the same subnet.

Wake-on-LAN

Basic Usage

bash
nefia power wake web-01

Flags

FlagDescriptionDefault
--proxyExplicitly specify a proxy agentAuto-selected
--waitBlock until the host comes onlinefalse
--timeoutTimeout for --wait60s

Automatic Proxy Selection

When --proxy is not specified, an online agent on the same /24 subnet as the target is automatically selected. The target host's local IP information is obtained from metadata collected during enrollment.

bash
# Auto-selection
nefia power wake db-01
 
# Explicit specification
nefia power wake db-01 --proxy web-01

Waiting for Online Status

When the --wait flag is used, WireGuard peer handshake status is polled at 5-second intervals until the host comes online.

bash
nefia power wake db-01 --wait --timeout 120s

A host is considered online if its handshake occurred within the last 3 minutes.

MAC Address Resolution

MAC addresses are resolved in the following priority order:

  1. host.mac — Manually specified in the configuration file
  2. host.meta.mac_addresses[0].mac — Automatically collected during enrollment

How It Works

plaintext
nefia power wake <host>
  1. Resolve MAC address
  2. Select proxy agent (same /24 subnet)
  3. Execute `nefia-agent wol --mac <MAC>` on the proxy via SSH
  4. Broadcast Magic Packet (102 bytes) via UDP (255.255.255.255:9)
  5. If --wait is set, monitor WireGuard handshake

Magic Packet Format

BytesContents
0-50xFF × 6 (broadcast marker)
6-101MAC address (6 bytes) × 16 repetitions

Prerequisites

To use Wake-on-LAN:

  • WoL must be enabled in the target PC's BIOS/UEFI
  • The network adapter must support WoL
  • At least one online agent must be on the same subnet
  • The target's MAC address must be recorded in the configuration or metadata

Remote Reboot and Shutdown

In addition to waking hosts, Nefia can reboot or shut down remote hosts.

CLI

bash
# Reboot a host
nefia power reboot --host my-pc
 
# Shut down a host
nefia power shutdown --host my-pc

MCP Tools

ToolDescription
nefia.power.wakeWake a sleeping host via Wake-on-LAN through a proxy agent on the same subnet.
nefia.power.rebootReboot a remote host. Requires confirmation or --yes flag.
nefia.power.shutdownShut down a remote host. Requires confirmation or --yes flag.