I am using an Ubuntu 18 on a virtualbox machine and I am trying to overwrite a netplan config related to an interface. There are two config files located in /etc/netplan/
.
50-cloud-init.yaml
:
network: ethernets: enp0s3: dhcp4: true match: macaddress: 02:d4:40:b8:a4:a0 set-name: enp0s3 version: 2
50-vagrant.yaml
:
--- network: version: 2 renderer: networkd ethernets: enp0s8: dhcp4: true enp0s9: dhcp4: true enp0s10: addresses: - 192.168.56.200/24
I want to overwrite some configurations in 60-myconfig.yaml
, such that enp0s8
gets a static IP address and does not use DHCP. However, I prefer to not to use interface name as the key and use match
instead. But it doesn't work:
--- network: version: 2 renderer: networkd ethernets: myinterface: match: name: enp0s8 dhcp4: false addresses: - 192.168.1.160/24
when I change key myinterface
to enp0s8
it works properly. I guess netplan does not support overwriting an interface config using match
. Is it true or I am doing something wrong??
match
. I can't find anything explicit in the docs that say this, but I tested a couple of different scenarios on Ubuntu 18.04 (netplan 0.99) and got the same results that you did50-vagrant.yaml
directly, then you could create a file/run/netplan/50-vagrant.yaml
that overrides it. (/run
is obviously volatile, so to make it "persist" you'd have to create a service that runs on boot and creates this file, either before netplan runs or afterwards and then callingnetplan apply
)