Is there a way to automatically add network interfaces to systemd-networkd and/or netplan?

systemd-networkd can apply a configuration to multiple interfaces at once, using a wildcard [Match].

For example:

# cat /etc/systemd/network/99-wildcard.network
[Match]
Name=en*

[Network]
DHCP=yes

This will bring up DHCP on any interface whose name starts with en (which is every wired interface).


This is possible using a match rule within the netplan config, for those who'd prefer to keep it all in one place. Here's a simple solution I've been using in my pre-configured images for USB interfaces with varying device names:

/etc/netplan/01-netcfg.yaml:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth:
      match:
        name: en*
      dhcp4: yes

Further details here: Netplan reference