From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 5052D1FF065 for ; Mon, 23 Nov 2026 17:48:12 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 1B3BE202B7; Mon, 23 Nov 2026 17:48:12 +0100 (CET) From: Gabriel Goller Date: Mon, 23 Nov 2026 17:48:03 +0100 Subject: [PATCH network] sdn: dhcp: do not start dnsmasq for zones without a vnet with subnets MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261123-sdn_dhcp_do-v1-1-4b55711e9620@proxmox.com> X-B4-Tracking: v=1; b=H4sIAEJuBGsC/yWMXQrCMBAGr1K+ZwPJSrV6FSklJqtdhaRk6w+U3 t2oj8Mws0C5CCuOzYLCT1HJqYLbNAijT1c2EiuDLO2co63RmIY4hmmI2Vjy+87bltrugFpMhS/ y/t1OSDy/crmj/wt9nG8c5u8L6/oBx0BOWXgAAAA= X-Change-ID: 20261123-sdn_dhcp_do-02a78a052589 To: pve-devel@lists.proxmox.com X-Mailer: b4 0.17-dev X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795452488047 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.211 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: QD72BRJZG5ADIPIP7ZCC5JFIOOHUUBHY X-Message-ID-Hash: QD72BRJZG5ADIPIP7ZCC5JFIOOHUUBHY X-MailFrom: g.goller@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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/. 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