brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: optional: true in netplan stops boot from waiting for an unplugged port

Netplan
~/tips/tip-netplan-optional-true

optional: true

A network port that is often down no longer holds up the startup.

A server with a second network port that is usually unplugged can sit and wait for it at every start. Netplan has a one line answer for that.

By default an interface is treated as required for boot. Mark the unreliable one as optional:

network:
  version: 2
  ethernets:
    enp3s0:
      dhcp4: true
    enp4s0:
      dhcp4: true
      optional: true

Here enp3s0 is the cable I care about and enp4s0 is the spare. The docs put it plainly: an optional device is not required for booting. The port is still configured, and it comes up whenever a cable shows up.

Test the file and apply it:

sudo netplan generate
sudo netplan apply

This also helps with a USB network adapter that you only plug in now and then, or a link to a test network that is switched off half the week.

Do not put it on the interface your services need. If something mounts a network share during startup and the only path to it is marked optional, the mount may run before the link is ready. Keep the setting for ports you can live without.

Further reading: Netplan YAML reference

More Netplan tips – to: 192.168.3.0/24 hidden: true lacp-rate: fast link-local: [] wakeonlan: true All Netplan tips (21) All topics

Link