Score:0

MTU specified in netplan is not applied at boot

ar flag

My netplan file looks like so:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 169.254.1.1/24
      mtu: 9000

After boot the eth0 interface takes the configured address, but the MTU is the default value of 1500.

If I run sudo netplan apply manually after boot, then the MTU increases to 9000 as expected.

Right after boot, the generated files for systemd-networkd look like so. These files do not change after manually applying the second time.

$ cat /run/systemd/network/10-netplan-eth0.link
[Match]
OriginalName=eth0

[Link]
WakeOnLan=off
MTUBytes=9000

$ cat /run/systemd/network/10-netplan-eth0.network
[Match]
Name=eth0

[Network]
Address=169.254.1.1/24

Nothing obvious stands out to me in the log of systemd-networkd, other than the order being different:

# at boot
Dec 13 06:29:35 ifcb110 systemd-networkd[3233]: eth0: IPv6 successfully enabled
Dec 13 06:29:35 ifcb110 systemd-networkd[3233]: eth0: Link UP
Dec 13 06:29:38 ifcb110 systemd-networkd[3233]: eth0: Gained carrier
Dec 13 06:29:39 ifcb110 systemd-networkd[3233]: eth0: Gained IPv6LL
Dec 13 06:29:39 ifcb110 systemd-networkd[3233]: eth0: Configured

# second time that works
Dec 13 06:39:46 ifcb110 systemd-networkd[6781]: eth0: Gained IPv6LL
Dec 13 06:39:46 ifcb110 systemd-networkd[6781]: eth0: Link is not managed by us
Dec 13 06:39:46 ifcb110 systemd-networkd[6781]: eth0: IPv6 successfully enabled
Dec 13 06:39:49 ifcb110 systemd-networkd[6781]: eth0: Gained carrier
Dec 13 06:39:49 ifcb110 systemd-networkd[6781]: eth0: Configured

Here's what netplan --debug apply outputs (abridged):

$ sudo netplan --debug apply
** (generate:7015): DEBUG: 06:50:14.054: Processing input file //etc/netplan/config.yaml..
** (generate:7015): DEBUG: 06:50:14.054: starting new processing pass
** (generate:7015): DEBUG: 06:50:14.054: eth0: setting default backend to 1
** (generate:7015): DEBUG: 06:50:14.054: Generating output files..
** (generate:7015): DEBUG: 06:50:14.055: NetworkManager: definition eth0 is not for us (backend 1)
DEBUG:netplan generated networkd configuration exists, restarting networkd
DEBUG:no netplan generated NM configuration exists
DEBUG:device eth0 operstate is up, not replugging
DEBUG:netplan triggering .link rules for eth0

What might be preventing the setting from taking effect the first time?

(I suspect something like a race between the eth0 interface becoming available and applying the udev rules in the .link file.)

ar flag
Likely to be this bug: https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/1724895
Score:0
ar flag

It sounds a bit like this bug which was closed a few years ago, but the problem still occurs for me.

Instead I ended up making a fix-mtu@.service unit file containing

[Unit]
Description=Fix MTU on Interface

[Service]
Type=oneshot
ExecStart=/sbin/ip link set dev %i mtu 9000

[Install]
WantedBy=sys-subsystem-net-devices-%i.device

I'm not really pleased with this workaround because it seems like systemd-networkd is supposed to do this for me.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.