]> git.proxmox.com Git - pve-manager.git/commitdiff
fix #5255: node: wol: configurable broadcast address
authorChristian Ebner <c.ebner@proxmox.com>
Tue, 26 Mar 2024 09:16:58 +0000 (10:16 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 28 Mar 2024 16:27:47 +0000 (17:27 +0100)
Allows to configure a custom broadcast address to use when sending a
wake on lan packet to wake a remote node.

Default behaviour remains to fallback to 255.255.255.255.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
PVE/API2/Nodes.pm
PVE/NodeConfig.pm

index 9ffe7494530ea96f1cfee5037e04cfbb3c8e0f9f..4f9640b2b5df2718e7c2d47e70583f469ebaae84 100644 (file)
@@ -700,11 +700,12 @@ __PACKAGE__->register_method({
        my $local_config = PVE::NodeConfig::load_config($local_node);
        my $local_wol_config = PVE::NodeConfig::get_wakeonlan_config($local_config);
        my $bind_iface = $local_wol_config->{'bind-interface'};
+       my $broadcast_addr = $local_wol_config->{'broadcast-address'} // '255.255.255.255';
 
        $mac_addr =~ s/://g;
        my $packet = chr(0xff) x 6 . pack('H*', $mac_addr) x 16;
 
-       my $addr = gethostbyname('255.255.255.255');
+       my $addr = gethostbyname($broadcast_addr);
        my $port = getservbyname('discard', 'udp');
        my $to = Socket::pack_sockaddr_in($port, $addr);
 
index ee316296cef3f639a0cb94c4830b8a65b17ca5f3..5fa8001c99d513d2153478231c6c8ce991e76fbe 100644 (file)
@@ -110,6 +110,13 @@ my $wakeonlan_desc = {
        format_description => 'bind interface',
        optional => 1,
     },
+    'broadcast-address' => {
+       type => 'string',
+       description => 'IPv4 broadcast address to use when sending wake on LAN packet',
+       format => 'ipv4',
+       format_description => 'IPv4 broadcast address',
+       optional => 1,
+    },
 };
 
 $confdesc->{wakeonlan} = {