3

I'm currently building pre-configured disk images for Ubuntu 18.04 servers. While the hardware is mostly the same, there are a few different network interfaces between the devices (and some are virtual machines rather than bare metal). Because of this I don't know exactly what network devices will be present beforehand or what they will be called (some have a single one called ens33, others have multiples called eno1, eno2, etc.)

systemd-networkd doesn't automatically bring up interfaces on, they have to be explicitly specified in config files.

I'm currently bypassing this by using NetworkManager instead of networkd since it will automatically bring up any interfaces it finds, but considering the Ubuntu installer seems to automatically add any interfaces it finds to netplan's config, I figure there must be a way to setup a service or something that does the same thing at startup. Anyone know a way to do this?

  • 2
    netplan looks like a solution in search of a problem. It will probably go away in the future. – Michael Hampton Jul 24 '18 at 18:17
4

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).

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.