问题原文
原帖链接 · RCH · CC BY-SA 4.0
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?
已采纳解答
原帖链接 · Michael Hampton · CC BY-SA 4.0
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).
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
