[update] Wake (and other) on LAN for VMs (v0.3)

Na geht doch! Biddeschön... Und wenn Du etwas fertiges/funktionierendes hast, immer gerne her damit - wird andere auch interessieren und zu verbessern gibt es immer etwas ;)
Okay, damit es keine Verwirrung gibt habe ich Release notes hinterlegt. Wurde am Mac gezippt, hoffe das macht keine Probleme beim entpacken.

EDIT: Offenbar hat macOS bei mir der datei `dosthol.service` automatisch eine Endung `.app` angehängt. Das ist natürlich falsch und muss rückgängig gemacht werden. Es ist eine Linux `.service`-Datei!
 

Attachments

  • dosthol-0.7.1.zip
    9.1 KB · Views: 293
Last edited:
  • Like
Reactions: Emilien
First of all, thanks for this great tool.
Problem for me is, it won‘t work across VLAN.
As long as the client running the script is in the same VLAN/Subnet as the Proxmox host everything works fine.
I‘ve tried with variations of the -i parameter but can‘t find a way to get it to work.
Could you explain how the parameter is expected to work across VLANs?
I‘ve also tried understanding the dostholc.sh script in the way, the given parameter is used, but i don‘t get it.
For my understanding the last command is always using 255.255.255.255 for broadcast.
 
Problem for me is, it won‘t work across VLAN.
As long as the client running the script is in the same VLAN/Subnet as the Proxmox host everything works fine.

Yes, but that's the meaning of VLAN, isn'r it? To my understand it should work when the host - where dosthold is running - is a member of all VLANs in question.

I‘ve also tried understanding the dostholc.sh script in the way, the given parameter is used, but i don‘t get it.
For my understanding the last command is always using 255.255.255.255 for broadcast.

You can't send a command like "hey MAC address, wake up" in a plain form to the network. That has to be encoded by xxd in the form of a specific header plus 16* target's MAC address before. This is what the script is doing up to the last line, where xxd encodes this as a "uppercase postscript binary " "string" and sends this as a broadcast (255.255.255.255, Port 9 UDP) by socat. No secrets, no magic, and that's the way of creating and sending a "magic packet" (WOL).
 
You can't send a command like "hey MAC address, wake up" in a plain form to the network. That has to be encoded by xxd in the form of a specific header plus 16* target's MAC address before. This is what the script is doing up to the last line, where xxd encodes this as a "uppercase postscript binary " "string" and sends this as a broadcast (255.255.255.255, Port 9 UDP) by socat. No secrets, no magic, and that's the way of creating and sending a "magic packet" (WOL).
I got that.
Still i don't get what the -i parameter is used for.
Could you explain that or even give an example?
I can see there's an validation on the given IP in the script but where is it used exactly?
 
Still i don't get what the -i parameter is used for.

The -i parameter was meant to send this broascast to a subnet other then your local, i.e. by VPN. This should work in principle, but never got this to work, so I left this as an idea for other developers.

I can see there's an validation on the given IP in the script but where is it used exactly?

This is just to ensure that the given subnet or IP is syntactically correct. You local broadcast normally is 255.255.255.255 (the default in dosthol), but as mentioned above, the idea was to give an IP address instead of an broadcast to send this packet to, like another PVE with dosthold connected by VPN.
 
  • Like
Reactions: lewebster
Hello!
I am running Proxmox 7.1-10 and I can't seem to get the service to start. This is readout I am getting when trying to start the service:

Code:
root@KLabsDev:~/pve-dosthol# systemctl status dosthol.service
● dosthol.service - dosthol (Do something on LAN)
     Loaded: loaded (/etc/systemd/system/dosthol.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2022-03-27 17:02:23 CDT; 8s ago
    Process: 2380425 ExecStart=/usr/local/bin/dosthold.sh (code=exited, status=203/EXEC)
   Main PID: 2380425 (code=exited, status=203/EXEC)
        CPU: 817us

Mar 27 17:02:23 KLabsDev systemd[1]: dosthol.service: Scheduled restart job, restart counter is at 5.
Mar 27 17:02:23 KLabsDev systemd[1]: Stopped dosthol (Do something on LAN).
Mar 27 17:02:23 KLabsDev systemd[1]: dosthol.service: Start request repeated too quickly.
Mar 27 17:02:23 KLabsDev systemd[1]: dosthol.service: Failed with result 'exit-code'.
Mar 27 17:02:23 KLabsDev systemd[1]: Failed to start dosthol (Do something on LAN).

I can't tell if I am skipping a specific step or if I am just missing a step somewhere. Any help would be super helpful!
Thanks!

EDIT:
I forgot the fundamentals. I needed to make sure the script was marked as executable and then reload the systemctl daemon after. As of right now it is working perfect! Thank you for making this!
 
Last edited:
thanks for this great tool.

Use it:
  1. Install daemon dependencies: $ apt install gawk socat xxd
  2. Copy dosthold.sh to /usr/local/bin
  3. Copy dosthol.service to /etc/systemd/system
Code:
# Update package list:
apt-get update
# Installation dependency:
apt install gawk socat xxd
# Change file permissions:
chmod +s /etc/systemd/system/dosthol.service
# enable dosthol
systemctl enable dosthol
# status dosthol
systemctl status dosthol

# Make sure your VM has a network device,dostholuses this line of command to read the Mac.(Please add a virtual network card under your direct network card virtual machine)
Code:
grep -r "net[0-9]:" /etc/pve/local/ | grep -ioE "([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}" | grep -io -m1 "${MAC}"

# Shut down the VM
# test wake_on_lan
Code:
bash /usr/local/bin/dostholc.sh -f wakeup -m XX:XX:XX:XX:XX:XX -v 1


感谢这个伟大的工具.

使用它:
  1. 安装守护进程依赖: $ apt install gawk socat xxd
  2. 复制 dosthold.sh 文件到这个目录 /usr/local/bin
  3. 复制 dosthol.service 文件到这个目录 /etc/systemd/system
Code:
# 更新软件包列表:
apt-get update
# 安装依赖:
apt install gawk socat xxd
# 更改文件权限:
chmod +s /etc/systemd/system/dosthol.service
# 打开 dosthol 自动启动
systemctl enable dosthol
# 启动 dosthol
systemctl status dosthol

# 请确保你的虚拟机拥有一个网络设备,dosthol 使用下面的命令查看虚拟机 MAC(请在你的直通网卡虚拟机下添加一个虚拟网卡)
Code:
grep -r "net[0-9]:" /etc/pve/local/ | grep -ioE "([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}" | grep -io -m1 "${MAC}"

# 关闭这台虚拟机
# 发送魔术包测试命令
Code:
bash /usr/local/bin/dostholc.sh -f wakeup -m XX:XX:XX:XX:XX:XX -v 1
 
Last edited:
ich hab noch nen Bug gefunden, wenn im PVE die Macadresse mit kleinen Buchstaben geschrieben ist startet die VM nicht, nur wenn die mit Großbuchstaben eingetragen ist
 
The -i parameter was meant to send this broascast to a subnet other then your local, i.e. by VPN. This should work in principle, but never got this to work, so I left this as an idea for other developers.



This is just to ensure that the given subnet or IP is syntactically correct. You local broadcast normally is 255.255.255.255 (the default in dosthol), but as mentioned above, the idea was to give an IP address instead of an broadcast to send this packet to, like another PVE with dosthold connected by VPN.
Theres a Linux Package called wakeonlan that works pretty nice for me to wake up VMs in PVE even from other VLANs than the PVE is associated to.
Syntax is like
Code:
wakeonlan -i %IP_OF_PVE_HOST% -p %PORT_YOU_WANT_TO_USE% %MAC_ADDRESS_OF_VM_OR_LXC%
.
So i guess every other WOL-Tool might work fine too to wake up VMs and LXCs in PVE.
 
Last edited:
  • Like
Reactions: hbokh
Tell me how to implement via vlan and other subnets. If I use it on the host, but if I use opensuse and vlan and vpn to it, then the packet does not reach
 
Hi,
i am using this awesome tool since a bunch of years. To make things easier to install and update across multiple devices i put everything to a github repository: Github repo

I hope nobody is offended i don't want to steal anyone's credits, only want to ease development and deployment.
@ojaksch: Please let me know if i should turn it private!
 
Hallo,
ich hab auch gesucht wie ich WOL für meine VM und CT bekomme. Bin hier fündig geworden und hab das ausprobiert.
Zuerst hat es nicht geklappt. Dann zusätzl. noch die dosthold.sh ausführbar gemacht.
Code:
chmod +x dosthold.sh

ls -lia
und alle haben die selben Rechte. Vielen Dank für das Script. Das ist so einfach nachbaubar, klasse. Angefangen März 2016. Lange Zeit hats niemand interessiert und nun waren doch schon einige sehr froh und dankbar.
:cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool::cool:
 
Last edited:
Moin Leute, ich find die Lösung mega, weiß aber leider nicht an welcher stelle und wie ich dateien einbaue. Kann mir jemand eine kurze Anleitung dazu geben? Wäre echt nett

LG
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!