all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH network] sdn: dhcp: do not start dnsmasq for zones without a vnet with subnets
Date: Mon, 23 Nov 2026 17:48:03 +0100	[thread overview]
Message-ID: <20261123-sdn_dhcp_do-v1-1-4b55711e9620@proxmox.com> (raw)

A zone with DHCP enabled but no vnet with a subnet still got a dnsmasq
instance. The interface= line for a vnet is only written once the vnet
has a subnet, so the instance config only has except-interface=lo. With
bind-dynamic, dnsmasq then binds port 53 on every address of the host,
including the vnets of other zones. Zones are configured in sorted
order, so every DHCP zone after the empty one then fails to start:

  dnsmasq: failed to create listening socket for fe80::d840:37ff:fea1:fa73%test2: Address already in use
  dnsmasq: FAILED to start up

This was preexisting but zones with a dedicated VRF are affected too.
dnsmasq runs via "ip vrf exec", but it binds link-local addresses with
sin6_scope_id set to the interface. The kernel then replaces the VRF
binding of the socket with that interface, so the instance still binds
to host and other zone interfaces, and also answers DNS there.

Only enable and start dnsmasq for a zone if at least one of its vnets
has a subnet, and thus an interface= line. before_regenerate already
stops and disables all instances, so a skipped zone stays down.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
Note that with this patch, a DHCP zone without a vnet that has a subnet
no longer gets a dnsmasq instance, even if the user added custom config
files (e.g. 90-custom.conf) in etc/dnsmasq.d/<zone>. I don't expect
anyone to rely on this, since that instance would also bind to every
address on the host and break the other zones
---
 src/PVE/Network/SDN/Dhcp.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/PVE/Network/SDN/Dhcp.pm b/src/PVE/Network/SDN/Dhcp.pm
index 10d7ee917da5..47161208c802 100644
--- a/src/PVE/Network/SDN/Dhcp.pm
+++ b/src/PVE/Network/SDN/Dhcp.pm
@@ -97,6 +97,8 @@ sub regenerate_config {
         eval { $dhcp_plugin->before_configure($zoneid, $zone) };
         die "Could not run before_configure for DHCP server $zoneid $@\n" if $@;
 
+        my $has_dhcp_vnet = 0;
+
         for my $vnetid (sort keys %{ $vnet_cfg->{ids} }) {
             my $vnet = $vnet_cfg->{ids}->{$vnetid};
             next if $vnet->{zone} ne $zoneid;
@@ -126,8 +128,13 @@ sub regenerate_config {
 
             eval { $dhcp_plugin->configure_vnet($config, $zoneid, $vnetid, $vnet) };
             warn "Could not configure vnet $vnetid: $@\n" if $@;
+            $has_dhcp_vnet = 1 if !$@ && @$config;
         }
 
+        # Without a vnet to serve, the DHCP server isn't restricted to any interface and binds to
+        # every address on the host, including those on vnets of other zones.
+        next if !$has_dhcp_vnet;
+
         eval { $dhcp_plugin->after_configure($zoneid, !$any_zone_needs_dhcp) };
         warn "Could not run after_configure for DHCP server $zoneid $@\n" if $@;
 

---
base-commit: e933d383aebdff9f31f6d00986331fc6e6dd898b
change-id: 20261123-sdn_dhcp_do-02a78a052589

Best regards,
--  
Gabriel Goller <g.goller@proxmox.com>





                 reply	other threads:[~2026-11-23 16:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261123-sdn_dhcp_do-v1-1-4b55711e9620@proxmox.com \
    --to=g.goller@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal