On Ubuntu 20.04, how can I configure DNS for all Ethernet interfaces, regardless of how they've been named? I have some machines with eth0
as the primary network interface and others with ens5
. I'd like to use the same DNS configuration regardless of interface names. A colleague had recommended NetPlan, so that's what I've been trying first. The following configuration (with placeholder IP addresses, domain names, and MAC addresses) avoids some errors, such as an unescaped *
being interpreted as a YAML alias attempt, or match: {name: {}}
generating a Name=
networkd configuration line that its logs flag as ignored. But it renders the machine unreachable.
network:
version: 2
ethernets:
all-ethernet-interfaces:
match:
name: "*"
dhcp4-overrides:
use-dns: no
nameservers:
addresses: [10.1.2.3, 10.1.2.4]
search: [my.domain.com]
The only other netplan configuration fragment is 50-cloud-init.yaml:
network:
ethernets:
eth0:
dhcp4: true
dhcp6: false
match:
macaddress: 01:20:34:50:67:08
set-name: eth0
version: 2
I have been able to work around the issue with duplicate, interface-specific, configuration sections, but I'd prefer to use a less repetitious and more flexible approach. I'm open to configuring systemd-networkd or systemd-resolved more directly instead of using netplan. I'll be using Ansible to apply the configuration once it's developed.