| Crates.io | wol-libvirt-gateway |
| lib.rs | wol-libvirt-gateway |
| version | 0.1.0 |
| created_at | 2025-06-17 08:14:01.522439+00 |
| updated_at | 2025-06-17 08:14:01.522439+00 |
| description | Wake-on-LAN to libvirt gateway |
| homepage | https://github.com/brunoproduit/wol-libvirt-gateway |
| repository | https://github.com/brunoproduit/wol-libvirt-gateway |
| max_upload_size | |
| id | 1715397 |
| size | 80,014 |
A simple Wake-on-LAN (WOL) gateway service for starting libvirt VMs. It listens for WOL "magic packets" on UDP port 9 (configurable), identifies the target MAC address, and if that MAC address belongs to a defined libvirt VM, it attempts to start that VM using the libvirt API.
This service is designed to be run on the same host as the libvirt daemon and the VMs. It's particularly useful for triggering VM power-on from external tools like Guacamole, which can send WOL packets.
⚠️ SECURITY NOTICE: This service is inherently insecure when exposed to the internet. Wake-on-LAN packets are plaintext and contain no authentication mechanism, besides an optional plaintext "password" that is intentionally ignored as it is insecure. Anyone who can send UDP packets to your service and knows (or can guess) a VM's MAC address can potentially start that VM. Only run this service on trusted local networks, if not localhost only.
virsh command execution).libvirtd daemon)Run the service with default settings:
wol-libvirt-gateway
This will:
127.0.0.1:9 (all interfaces, UDP port 9)qemu:///systemwol-libvirt-gateway --help
Common options:
--listen-address <IP:PORT> - Address and port to listen on (default: 127.0.0.1:9)--libvirt-uri <URI> - Libvirt connection URI (default: qemu:///system)Examples:
# Listen only on localhost, port 9009
wol-libvirt-gateway --listen-address 127.0.0.1:9009
# Use session libvirt instead of system
wol-libvirt-gateway --libvirt-uri qemu:///session
Enable and start the service:
sudo cp ./packaging/systemd/wol-libvirt-gateway.service /etc/systemd/system/wol-libvirt-gateway.service
sudo systemctl daemon-reload
sudo systemctl enable wol-libvirt-gateway.service
sudo systemctl start wol-libvirt-gateway.service
Check service status:
sudo systemctl status wol-libvirt-gateway.service
sudo journalctl -u wol-libvirt-gateway.service -f
Install libvirt development libraries:
Ubuntu/Debian:
sudo apt install libvirt-dev pkg-config
RHEL/CentOS/Fedora:
sudo dnf install libvirt-devel pkg-config
# or: sudo yum install libvirt-devel pkg-config
Arch Linux:
sudo pacman -S libvirt pkg-config
Clone and build:
git clone https://github.com/brunoproduit/wol-libvirt-gateway.git
cd wol-libvirt-gateway
cargo build
Run in development mode:
cargo run -- --help
cargo run -- --listen-address 127.0.0.1:9009
Run tests:
cargo test
You can use tools like wakeonlan or etherwake to send WOL packets. Many network management tools and virtualization platforms (like Guacamole) also have built-in WOL functionality.
Install wakeonlan:
# Ubuntu/Debian
sudo apt install wakeonlan
# RHEL/CentOS/Fedora
sudo dnf install wakeonlan
# Arch Linux
sudo pacman -S wakeonlan
Send a WOL packet:
wakeonlan AA:BB:CC:DD:EE:FF -i 127.0.0.1 # Replace with your VM's MAC address
127.0.0.1:9).shutoff, shutdown, or crashed, the service attempts to start it.Permission denied connecting to libvirt:
libvirtd grouplibvirtd service is running: sudo systemctl status libvirtdVM not starting:
virsh list --allsudo journalctl -u libvirtd.serviceTo find the MAC address of your libvirt VMs:
sudo virsh domiflist <vm_name>
Check service logs:
# systemd service logs
sudo journalctl -u wol-libvirt-gateway.service -f
# If running manually, increase verbosity
RUST_LOG=debug wol-libvirt-gateway
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.