Wake on Lan for Virtual Machines for 6.1+


dmacias

Recommended Posts

Hi,

I'm new at Unraid, installed it yesterday first time (Trial). The goal is to find a solution for VMs for WoL over Internet and I found it.

Installed your VM WoL and it works really nice. Can now start my Test VM with a command line tool from any place in the world, tried it from NZ, RU, Emitrates and a few other locations. Thats what i was looking for.

THX for this App.

Link to comment
  • 2 weeks later...

Hi, I tried this plugin where a Linux VM is suspended via the VM itself. Then tried waking it up using the WakeOnLAN Plugin - it worked!

 

However, I tried waking up the Linux VM from  another Linux Machine using etherwake command, but it failed. 

 

I get error:

SIOCGIFHWADDR on br0 failed: No such device

or

SIOCGIFHWADDR on eth0 failed: No such device

 

Any ideas?

 

UPDATE:

Did a wakeonlan command and it worked.

Edited by garydapogi
updated the post
Link to comment
  • 3 weeks later...

Hi everyone,

 

after enabling VLANs on the unraid machine and enabling trunk on the switchport, Wake on LAN for the VMs does not work anymore. The VMs still are on br0 and default / native VLAN ID is 1. WoL package both sent from Guacamole Docker but also sent from VLAN 1 network (192.168.1.0/24) do not wake any machine up..

 

Any ideas?

 

 

Switch configuration:

 

Spoiler

Layer3#sh runn
Building configuration...

Current configuration : 5726 bytes
!
! Last configuration change at 15:35:39 UTC Sat Jan 1 2000 by admin
! NVRAM config last updated at 15:35:57 UTC Sat Jan 1 2000 by admin
!
version 15.2
no service pad
service timestamps debug datetime msec
service timestamps log datetime msec
service password-encryption
!
hostname Layer3
!
boot-start-marker
boot-end-marker
!
enable secret 5 #######################
enable password 7 #######################
!
username admin password 7 #######################
no aaa new-model
system mtu routing 1500
ip routing
!
!
ip domain-name fritz.box
!
!
!
!
!
!
!
crypto pki trustpoint TP-self-signed-1733138816
 enrollment selfsigned
 subject-name cn=IOS-Self-Signed-Certificate-1733138816
 revocation-check none
 rsakeypair TP-self-signed-1733138816
!
!
crypto pki certificate chain TP-self-signed-1733138816
 certificate self-signed 01
  3082022B 30820194 A0030201 02020101 300D0609 2A864886 F70D0101 05050030
  31312F30 2D060355 04031326 494F532D 53656C66 2D536967 6E65642D 43657274
  69666963 6174652D 31373333 31333838 3136301E 170D3030 30313031 30303038
  32385A17 0D323030 31303130 30303030 305A3031 312F302D 06035504 03132649
  4F532D53 656C662D 5369676E 65642D43 65727469 66696361 74652D31 37333331
  33383831 3630819F 300D0609 2A864886 F70D0101 01050003 818D0030 81890281
  81008EFE A6B4AE24 2B4DE353 09341A30 9A8FC9F6 784F4681 001C1204 5AD17F07
  8A287C0E 1D4C7B1E 4F8BD451 DA06EE35 05C057C2 3C534187 33F9C45E 675C5B22
  2650CF8C 174A8F73 4E4DC337 F9268830 B16E3C15 FFB8D0C8 80016F73 0218D25A
  B339627E 5A414170 E77BB28D F29A53DF 443107D3 0896D04B 22C28897 C5855682
  3F8D0203 010001A3 53305130 0F060355 1D130101 FF040530 030101FF 301F0603
  551D2304 18301680 1442C5D8 A54AB7DA 1B9D2E10 68910F56 BD6BA69E FC301D06
  03551D0E 04160414 42C5D8A5 4AB7DA1B 9D2E1068 910F56BD 6BA69EFC 300D0609
  2A864886 F70D0101 05050003 81810029 6D55A857 4D3637D6 C6AD7EDA E8449203
  F73349DD AEF03904 B23A270C 48E34AE0 AD0F25A7 90F1B2F6 615E9B3A 9F312634
  9CC317F9 AC540112 97130D4A ACC9C229 2C00DE8C D55772BB 675519CF B1400E60
  2BD3A5AF D8DF8F78 938826ED 89DFA48A 772B9BAC 24F37F25 118E0240 23D9257F
  0BF84C4F 1CF5F019 DE30EF93 CA04E9
        quit
!
spanning-tree mode rapid-pvst
spanning-tree extend system-id
!
!
!
!
vlan internal allocation policy ascending
!
ip ssh version 2
!
!
!
!
!
!
!
!
!
!
interface GigabitEthernet0/1
 description Uplink FRITZ!Box
 switchport mode access
!
interface GigabitEthernet0/2
 description Uplink FRITZ!Gast
 switchport access vlan 2
 switchport mode access
!
interface GigabitEthernet0/3
 description Uplink Layer2
 switchport mode trunk
!
interface GigabitEthernet0/4
 description Uplink Layer2-2
 switchport mode trunk
!
interface GigabitEthernet0/5
 description Uplink Server
 switchport mode trunk
!
interface GigabitEthernet0/6
 description Uplink TP-Link Switch
 switchport mode access
!
interface GigabitEthernet0/7
!
interface GigabitEthernet0/8
!
interface GigabitEthernet0/9
 no keepalive
!
interface GigabitEthernet0/10
 no keepalive
!
interface GigabitEthernet0/11
!
interface GigabitEthernet0/12
 description VLAN3
 switchport access vlan 3
 switchport mode access
!
interface Vlan1
 description Native
 ip address 192.168.1.19 255.255.255.0
!
interface Vlan2
 description Guest
 no ip address
!
interface Vlan3
 description T0r
 no ip address
!
ip default-gateway 192.168.1.1
ip forward-protocol nd
ip http server
ip http secure-server
!
!
!
!
snmp-server community public RO
snmp-server community private RW
snmp-server location Abstellschrank
snmp-server enable traps snmp authentication linkdown linkup coldstart warmstart
snmp-server enable traps transceiver all
snmp-server enable traps call-home message-send-fail server-fail
snmp-server enable traps tty
snmp-server enable traps license
snmp-server enable traps auth-framework sec-violation
snmp-server enable traps cluster
snmp-server enable traps config-copy
snmp-server enable traps config
snmp-server enable traps config-ctid
snmp-server enable traps trustsec-sxp conn-srcaddr-err msg-parse-err conn-config-err binding-err conn-up conn-down binding-expn-fail oper-nodeid-change binding-conflict
snmp-server enable traps energywise
snmp-server enable traps fru-ctrl
snmp-server enable traps entity
snmp-server enable traps event-manager
snmp-server enable traps ike policy add
snmp-server enable traps ike policy delete
snmp-server enable traps ike tunnel start
snmp-server enable traps ike tunnel stop
snmp-server enable traps ipsec cryptomap add
snmp-server enable traps ipsec cryptomap delete
snmp-server enable traps ipsec cryptomap attach
snmp-server enable traps ipsec cryptomap detach
snmp-server enable traps ipsec tunnel start
snmp-server enable traps ipsec tunnel stop
snmp-server enable traps ipsec too-many-sas
snmp-server enable traps power-ethernet police
snmp-server enable traps cpu threshold
snmp-server enable traps bridge newroot topologychange
snmp-server enable traps stpx inconsistency root-inconsistency loop-inconsistency
snmp-server enable traps syslog
snmp-server enable traps vtp
snmp-server enable traps vlancreate
snmp-server enable traps vlandelete
snmp-server enable traps flash insertion removal
snmp-server enable traps port-security
snmp-server enable traps envmon fan shutdown supply temperature status
snmp-server enable traps stackwise
snmp-server enable traps bulkstat collection transfer
snmp-server enable traps errdisable
snmp-server enable traps mac-notification change move threshold
snmp-server enable traps vlan-membership
!
line con 0
 logging synchronous
 login local
line vty 0 4
 password 7 #######################
 login local
 transport input ssh
line vty 5 15
 password 7 #######################
 login local
 transport input ssh
!
!
end

 

 

 

unraid Network Settings:

 

Spoiler

Download.thumb.png.a3cd6c7e2681d769082b5d58869dd44e.png

 

 

VM XML:

Spoiler

<?xml version='1.0' encoding='UTF-8'?>
<domain type='kvm'>
  <name>##########</name>
  <uuid>73712027-ecca-9ec3-490a-ce837b564c47</uuid>
  <description>Windows 7 (32-Bit)</description>
  <metadata>
    <vmtemplate xmlns="unraid" name="Windows 7" icon="windows7.png" os="windows7"/>
  </metadata>
  <memory unit='KiB'>3145728</memory>
  <currentMemory unit='KiB'>3145728</currentMemory>
  <memoryBacking>
    <nosharepages/>
  </memoryBacking>
  <vcpu placement='static'>4</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='0'/>
    <vcpupin vcpu='1' cpuset='1'/>
    <vcpupin vcpu='2' cpuset='2'/>
    <vcpupin vcpu='3' cpuset='3'/>
  </cputune>
  <os>
    <type arch='x86_64' machine='pc-i440fx-4.2'>hvm</type>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
      <vendor_id state='on' value='none'/>
    </hyperv>
  </features>
  <cpu mode='host-passthrough' check='none' migratable='on'>
    <topology sockets='1' dies='1' cores='4' threads='1'/>
    <cache mode='passthrough'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='hypervclock' present='yes'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/local/sbin/qemu</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writeback'/>
      <source file='/mnt/user/domains/Elsa-ETKA/Elsa-ETKA.img'/>
      <target dev='hdc' bus='virtio'/>
      <boot order='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:00:5f:f2:81'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <channel type='unix'>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'>
      <address type='usb' bus='0' port='1'/>
    </input>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='0.0.0.0' keymap='de'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </memballoon>
  </devices>
</domain>
 

 

Edited by 3dee
added VM XML
Link to comment
  • 2 months later...
  • 2 months later...

Hello @dmacias

 

How are you? Hope you are doing well.

 

I started having issues with WOL plugin recently - it just won't start. I tried enabling/disabling from the VM Manager settings page, I tried re-installing the plugin as well as python2 in nerdpack, The daemon is not running. When trying to manually trigger start/stop scripts there are no errors thrown. When trying "python  /usr/local/emhttp/plugins/libvirtwol/scripts/libvirtwol.py br0" I am getting "GLIBC_2.33 not found, required by /usr/lib64/libpython2.7.so.1.0". I suspect an update for python in Nerdpack might have happened which triggered this (I should have probably followed the "don't touch it if aint broken" approach..., I might have accidently updated python but I can't remember if that is the case). Would you be able to advise me please?

 

Thank you.

 

 

  • Like 4
Link to comment
  • 2 weeks later...

I had the same issue and solved it that way:

 

1. Uninstall Python2 from the Nerd Pack Plugin

2. cli into your unraid

3. Download Python2 for Slackware: wget https://slackware.uk/slackware/slackware64-14.2/slackware64/d/python-2.7.11-x86_64-2.txz

4. Install Python2: upgradepkg --install-new python-2.7.11-x86_64-2.txz

 

For the last step I went to Settings, VM Manager, Advanced View enabled, Libvirt wake on lan disable, then enable again.

 

Status: Running :)

  • Like 1
  • Thanks 5
Link to comment
I had the same issue and solved it that way:
 
1. Uninstall Python2 from the Nerd Pack Plugin
2. cli into your unraid
3. Download Python2 for Slackware: wget https://slackware.uk/slackware/slackware64-14.2/slackware64/d/python-2.7.11-x86_64-2.txz
4. Install Python2: upgradepkg --install-new python-2.7.11-x86_64-2.txz
 
For the last step I went to Settings, VM Manager, Advanced View enabled, Libvirt wake on lan disable, then enable again.
 
Status: Running :)
Thanks I reverted the Nerdpack python 2

Sent from my SM-N970U using Tapatalk

  • Thanks 1
Link to comment
  • 1 month later...

Hi,

 

Apologies if this might be a dumb question, but, does this plugin also work with an ethernet card passed through, with no MAC address defined in the XML file ?

 

Captura de ecrã 2021-10-30, às 18.26.08.png

 

Installed as per instructions, but /var/log/libvirt/libvirtwakeonlan.log keeps telling me: "2021-10-30 17:27:08|INFO|Didn't find a VM with MAC address b4:2e:99:30:81:fc"...

 

I've got a MacOS Monterey VM machine, configured with IntelMausi.kext with -mausiwol boot argument on OpenCore.

 

I'm sending the WOL "magic" packet via my MacBooPro, with shell command: wakeonlan  B4:2E:99:30:81:FC   

(the wakeonlan shell command was installed via "brew install wakeonlan"and I'm able to remote WOL a real laptop, with same command using its own MAC )

Edited by augustopaulo
Link to comment
  • 4 weeks later...

Thanks for this missing piece of software! 

I read the entire thread; I have only installed python2-2.7.18-x86_64-4.txz, have setup the default bridge (br1.30) in vm-manager and your pkg shows "running" - but nothing.

The machine in case is a win10-vm which had it enabled as baremetal; as vm now there's no wol-option in the adapter-configuration within windows itself, and accessing the BIOS doesn't give me a wol-option, neither machine-type i440fx-4.2 nor q35-4.2.

I'm trying to wake the machines up from the fw/pfsense directly, no dice.

 

How could I troubleshoot furhter? Does the default vm-bridge have to be on the vlan where the vms sit i.e. br1.3 or on the general interface br1?

Thanks for your time!

Link to comment
  • 4 months later...
38 minutes ago, Linguafoeda said:

is there a settings menu / how do i use this software?

Go into Settings - VM Manager and enable advanced view. You should find Libvirt wake on lan. Other than on / off there are no settings. When running, VMs will wake up on magic packet.

Edited by 3dee
Link to comment
  • 4 months later...

PSA:

 

This plugin is currently being marked as deprecated for 6.11.0.  This is because @dmacias does not appear to be active and/or maintaining the plugin anymore, and this plugin has a dependency upon Python 2 being installed from NerdPack (which will be marked as being incompatible).

 

If you've come to rely upon this plugin, then you do not have to uninstall it, but you will be doing your own package management in installing (and maintaining) Python 2 https://forums.unraid.net/topic/42320-wake-on-lan-for-virtual-machines-for-61/?do=findComment&comment=1029485

 

 

Note that if some other author decides to fork this plugin (or create an auxiliary plugin to install Python 2) then this deprecation will be reversed if/when I am notified. 

Link to comment
  • 4 months later...
  • 1 month later...
On 10/30/2021 at 7:30 PM, augustopaulo said:

Hi,

 

Apologies if this might be a dumb question, but, does this plugin also work with an ethernet card passed through, with no MAC address defined in the XML file ?

 

Captura de ecrã 2021-10-30, às 18.26.08.png

 

 

Well it has been a while and you surely have moved on, but I had the same problem. This plugin won't work because the original developer of libvirtwol used a method to identify the vm to wake up by parsing the XML files of all the vm.

Of course a passed through NIC is just another device and not identified as a NIC with a MAC address in the XML file.

 

I considered modifying libvirtwol to make direct API call to libvirt wihtout using the XML parsing method but I know enough of dumb scripting and google to patch up something from different sources.

 

This script will listen to magic packet on the host, when receiving a magic packet to a known MAC adress it will start a virsh command to resume the VM depending of its state.

 

#!/bin/bash

# listen to udp port 9 for packets & check if it is a magic packet

while true
do
        nc-openbsd -dnlu -p 9 | stdbuf -o0 xxd -c 6 -p -l 12 | stdbuf -o0 grep -v 'ffffffffffff' | while read
        do
                mac="${REPLY:0:2}:${REPLY:2:2}:${REPLY:4:2}:${REPLY:6:2}:${REPLY:8:2}:${REPLY:10:2}"
                echo "Got triggered with MAC address $mac"

                # compare the MAC address with the magic packet
                if [ "$mac" == "<fill in with the vm mac address>" ] 
                then
                        state=$(virsh list --all|awk -v vm="vm name" '{ if ($2 == vm ) print $3 }')
                        echo "$vm in $state state"

                        # dependent of the state, resume, start or nothing
                        [ $state == "paused" ] && virsh -q resume $vm && virsh domtime --domain $vm --now
                        [ $state == "shut" ] && virsh -q start $vm
                        [ $state == "pmsuspended" ] && virsh dompmwakeup $vm
                        [ $state == "running" ] && echo Nothing to do $vm is already running
                fi
        done
done

 

You just have to replace in the mac address you want to wake up, and the "vm name".

Then configure it with the user script plugin to launch with unraid.

 

The script rely on nc-openbsd, so it has to be installed somehow on unraid.

Link to comment
  • 1 month later...

Thank you for the script. I tried to implement it on my server but to no success. I tried to install nc-openbsd via Slackware but sadly still get an error: 

nc-openbsd: error while loading shared libraries: libbsd.so.0: cannot open shared object file: No such file or directory

stdbuf: failed to run command 'xxd': No such file or directory.

 

Do you have a working way to install nc-openbsd as it is currently not available via Nerd Tools?

Link to comment
26 minutes ago, hot22shot said:

 

I used un-get : https://github.com/ich777/un-get

Thank you for the quick response. I removed the manually installed package and installed via un-get. (It was the same package anyways) 

"Currently installed package(s) by un-get:

netcat-openbsd-1.219-x86_64-1cf.txz"

 

Still get the same error:

nc-openbsd: error while loading shared libraries: libbsd.so.0: cannot open shared object file: No such file or directory.

 

I tried rebooting and reinstalling but still no luck. You have any other idea?

Link to comment
12 minutes ago, Drycane said:

Thank you for the quick response. I removed the manually installed package and installed via un-get. (It was the same package anyways) 

"Currently installed package(s) by un-get:

netcat-openbsd-1.219-x86_64-1cf.txz"

 

Still get the same error:

nc-openbsd: error while loading shared libraries: libbsd.so.0: cannot open shared object file: No such file or directory.

 

I tried rebooting and reinstalling but still no luck. You have any other idea?

 

My server is offline so I can't test but did you tried to install libbsd with un-get ?

Link to comment

It's always the obvious things. Thank you so much. I got it to work. Sadly it didn't work with the variable but after editing the startup script by adding sudo and the VM Name it now works with Guacamole. Thank you for your assistance!

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.