Le WOL natif sur les VM (et contenair LXC) de Proxmox n'existe pas à l'heure actuelle. Il est possible de contourner ce problème par une capture de trame puis un réveil de la VM par Proxmox.
source: https://forum.proxmox.com/threads/wake-on-lan-wol-for-vms-and-containers.143879/
Sur le PVE qui héberge les VMs, on va créer un script qui va intercepter les trames WOL destinées à la VM hébergée. Une fois la VM identifée, une commande qm ou pct allumera la machine.
Pour cela, depuis l'interface Proxmox manager
mkdir script
cd script vi wol_VM.sh
#!/bin/bash
# Attempts to start Proxmox VM or LXC that matches MAC address received on WOL message
# This could be dangerous if abused by spamming the interface with many packages
# so I would like to try no more than once per 5 seconds.
# In my case useful with Moonlight client
# Uses tcpdump on default proxmox interface, change the interface if needed.
while true; do
sleep 5
wake_mac=$(tcpdump -c 1 -UlnXi vmbr1 ether proto 0x0842 or udp port 9 2>/dev/null |\
sed -nE 's/^.*20: (ffff|.... ....) (..)(..) (..)(..) (..)(..).*$/\2:\3:\4:\5:\6:\7/p')
echo "Captured magic packet for address: \"${wake_mac}\""
echo -n "Looking for existing VM: "
matches=($(grep -il ${wake_mac} /etc/pve/qemu-server/*))
if [[ ${#matches[*]} -eq 0 |]]; then
echo "${#matches[*]} found"
echo -n "Looking for existing LXC: "
matches=($(grep -il ${wake_mac} /etc/pve/lxc/*))
if [[ ${#matches[*]} -eq 0 |]]; then
echo "${#matches[*]} found"
continue
elif [[ ${#matches[*]} -gt 1 |]]; then
echo "${#matches[*]} found, using first found"
else
echo "${#matches[*]} found"
fi
vm_file=$(basename ${matches[0]})
vm_id=${vm_file%.*}
details=$(pct status ${vm_id} -verbose | egrep "^name|^status")
name=$(echo ${details} | awk '{print $2}')
status=$(echo ${details} | awk '{print $4}')
if [[ "${status}" != "stopped" |]]; then
echo "SKIPPED CONTAINER ${vm_id} : ${name} is ${status}"
else
echo "STARTING CONTAINER ${vm_id} : ${name} is ${status}"
pct start ${vm_id}
fi
continue
elif [[ ${#matches[*]} -gt 1 |]]; then
echo "${#matches[*]} found, using first found"
else
echo "${#matches[*]} found"
fi
vm_file=$(basename ${matches[0]})
vm_id=${vm_file%.*}
details=$(qm status ${vm_id} -verbose | egrep "^name|^status")
name=$(echo ${details} | awk '{print $2}')
status=$(echo ${details} | awk '{print $4}')
if [[ "${status}" != "stopped" |]]; then
echo "SKIPPED VM ${vm_id} : ${name} is ${status}"
else
echo "STARTING VM ${vm_id} : ${name} is ${status}"
qm start ${vm_id}
fi
done
chmod +x wol_VM.sh
Ce script doit écouter en permanence les requetes de WOL sur l'interface de votre PVE (ici vmbr0). On va donc le mettre dans un service.
vi /etc/systemd/system/pve-wakeonlanVM.service
coller le contenu:
[Unit] Description=Wake-on-LAN for Proxmox Virtual Environments After=network.target [Service] Type=simple Restart=always User=root ExecStart=/root/script/wol_VM.sh [Install] WantedBy=multi-user.target
systemctl enable system/pve-wakeonlanVM.service
systemctl start system/pve-wakeonlanVM.service
systemctl satus system/pve-wakeonlanVM.service
Testez le réveil d'une VM éteinte sur votre PVE depuis une machine tier. ATTENTION vérifier d'abord avec une machine tier qui soit sur le meme switch que votre PVE pour vous éliminer un éventuel probleme de franchissement de commutateur, routeur, etc…