From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 6CA501FF15E for <inbox@lore.proxmox.com>; Tue, 20 May 2025 14:44:11 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0C3551CF9E; Tue, 20 May 2025 14:43:40 +0200 (CEST) From: Filip Schauer <f.schauer@proxmox.com> To: pve-devel@lists.proxmox.com Date: Tue, 20 May 2025 14:42:55 +0200 Message-Id: <20250520124257.165949-8-f.schauer@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250520124257.165949-1-f.schauer@proxmox.com> References: <20250520124257.165949-1-f.schauer@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.016 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH container 7/9] configure static IP in LXC config for custom entrypoint X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> When a container uses the default `/sbin/init` entrypoint, network interface configuration is usually managed by processes within the container. However, containers with a different entrypoint might not have any internal network management process. Consequently, IP addresses might not be assigned. This change ensures that a static IP address is explicitly set in the LXC config for the container. Signed-off-by: Filip Schauer <f.schauer@proxmox.com> --- src/PVE/LXC.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index b2be27e..0131ac3 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -818,6 +818,18 @@ sub update_lxc_config { if ($lxc_major >= 4) { $raw .= "lxc.net.$ind.script.up = /usr/share/lxc/lxcnetaddbr\n"; } + + if (!defined($d->{link_down}) || $d->{link_down} != 1 + && PVE::LXC::Config->get_entrypoint($conf) ne "/sbin/init" + ) { + $raw .= "lxc.net.$ind.ipv4.address = $d->{ip}\n" + if defined($d->{ip}) && $d->{ip} !~ /^(dhcp|manual)$/; + $raw .= "lxc.net.$ind.ipv4.gateway = $d->{gw}\n" if defined($d->{gw}); + $raw .= "lxc.net.$ind.ipv6.address = $d->{ip6}\n" + if defined($d->{ip6}) && $d->{ip6} !~ /^(auto|dhcp|manual)$/; + $raw .= "lxc.net.$ind.ipv6.gateway = $d->{gw6}\n" if defined($d->{gw6}); + $raw .= "lxc.net.$ind.flags = up\n"; + } } my $had_cpuset = 0; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel