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: netplan match and set-name give a network card a name that stays put

Netplan
~/tips/tip-netplan-match-set-name

ip -br link

Rename an interface by its MAC address so the config keeps pointing at it.

Interface names like enp3s0 follow the slot the card sits in. Move the card or add another one and the name can change, and your config no longer matches.

Netplan can select the card by its MAC address and give it a name of your own. Look up the address first:

ip -br link

Then use it under match:

network:
  version: 2
  ethernets:
    lan:
      match:
        macaddress: "52:54:00:12:34:56"
      set-name: lan0
      dhcp4: true

The key lan is only a label inside netplan. match picks the physical device and set-name renames it to lan0, which then shows up in ip, in firewall rules and in logs. I like names that say what a port is for.

A reboot is the reliable way to see the new name, since a card that is already up may keep the old one until then. Keep a console handy if this is your only network port.

Replacing the card means a new MAC address, so the match fails and the interface stays unconfigured until you update the file. Firewall rules or scripts that still mention the old name need the same edit.

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