From: Ilan Karasik <ilankarasik@gmail.com>
To: pve-devel@lists.proxmox.com
Cc: iamkarasik <ilankarasik@gmail.com>
Subject: [PATCH v3] fix #7571: emit mtu in ifupdown-based LXC guests
Date: Mon, 7 Sep 2026 11:39:21 -0400 [thread overview]
Message-ID: <20260907153921.852786-1-ilankarasik@gmail.com> (raw)
In-Reply-To: <1788789833.n8xgk28l2s.astroid@yuna.none>
From: iamkarasik <ilankarasik@gmail.com>
This fixes a bug where custom mtu settings applied to an LXC container
are silently ignored during network setup for Debian-based guests
using ifupdown.
Because the Proxmox network setup was failing to write the mtu value
to the guest's `/etc/network/interfaces` file, the container would
always default to an mtu of 1500.
This patch resolves the issue by writing the `mtu <value>` directive into the
guest's network configuration file at /etc/network/interfaces. This
configuration applies to static, dhcp, and manual configurations.
Signed-off-by: Ilan Karasik <ilankarasik@gmail.com>
---
src/PVE/LXC/Setup/Debian.pm | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/PVE/LXC/Setup/Debian.pm b/src/PVE/LXC/Setup/Debian.pm
index 837397b..fd4a7d4 100644
--- a/src/PVE/LXC/Setup/Debian.pm
+++ b/src/PVE/LXC/Setup/Debian.pm
@@ -284,6 +284,7 @@ sub setup_network {
$net->{needsroute6} = 1;
}
}
+ $net->{mtu} = $d->{mtu} if defined($d->{mtu});
$networks->{ $d->{name} } = $net if keys %$net;
}
}
@@ -298,6 +299,7 @@ sub setup_network {
my $done_auto = {};
my $done_v4_hash = {};
my $done_v6_hash = {};
+ my $done_mtu_hash = {};
my ($os, $version) = ($conf->{ostype}, $self->{version});
my $print_section = sub {
@@ -317,7 +319,12 @@ sub setup_network {
if (!defined($net->{address})) {
# no address => no iface line
} elsif ($net->{address} =~ /^(dhcp|manual)$/) {
- $interfaces .= "iface $ifname inet $1\n\n";
+ $interfaces .= "iface $ifname inet $1\n";
+ if (defined($net->{mtu}) && !$done_mtu_hash->{$ifname}) {
+ $interfaces .= "\tmtu $net->{mtu}\n";
+ $done_mtu_hash->{$ifname} = 1;
+ }
+ $interfaces .= "\n";
} else {
$interfaces .= "iface $ifname inet static\n";
if (
@@ -329,6 +336,10 @@ sub setup_network {
$interfaces .= "\taddress $net->{address}\n" if defined($net->{address});
$interfaces .= "\tnetmask $net->{netmask}\n" if defined($net->{netmask});
}
+ if (defined($net->{mtu}) && !$done_mtu_hash->{$ifname}) {
+ $interfaces .= "\tmtu $net->{mtu}\n";
+ $done_mtu_hash->{$ifname} = 1;
+ }
remove_gateway_scripts($section->{attr});
if (defined(my $gw = $net->{gateway})) {
if ($net->{needsroute}) {
@@ -348,7 +359,12 @@ sub setup_network {
if (!defined($net->{address6})) {
# no address => no iface line
} elsif ($net->{address6} =~ /^(auto|dhcp|manual)$/) {
- $interfaces .= "iface $ifname inet6 $1\n\n";
+ $interfaces .= "iface $ifname inet6 $1\n";
+ if (defined($net->{mtu}) && !$done_mtu_hash->{$ifname}) {
+ $interfaces .= "\tmtu $net->{mtu}\n";
+ $done_mtu_hash->{$ifname} = 1;
+ }
+ $interfaces .= "\n";
} else {
$interfaces .= "iface $ifname inet6 static\n";
if (
@@ -360,6 +376,10 @@ sub setup_network {
$interfaces .= "\taddress $net->{address6}\n" if defined($net->{address6});
$interfaces .= "\tnetmask $net->{netmask6}\n" if defined($net->{netmask6});
}
+ if (defined($net->{mtu}) && !$done_mtu_hash->{$ifname}) {
+ $interfaces .= "\tmtu $net->{mtu}\n";
+ $done_mtu_hash->{$ifname} = 1;
+ }
remove_gateway_scripts($section->{attr});
if (defined(my $gw = $net->{gateway6})) {
if ($net->{needsroute6}) {
@@ -450,6 +470,7 @@ sub setup_network {
|| $aname eq 'netmask'
|| $aname eq 'gateway'
|| $aname eq 'broadcast'
+ || $aname eq 'mtu'
) {
# skip
} else {
--
2.51.2
prev parent reply other threads:[~2026-09-08 7:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 23:00 [PATCH pve-container] fix #7571: emit mtu in ifupdown-based LXC guests Ilan Karasik
2026-06-16 10:22 ` Fabian Grünbichler
2026-06-17 18:32 ` [PATCH v2] " Ilan Karasik
2026-09-07 14:04 ` Fabian Grünbichler
2026-09-07 15:39 ` Ilan Karasik [this message]
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=20260907153921.852786-1-ilankarasik@gmail.com \
--to=ilankarasik@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox