I have a couple netplan config files, one that configures the machine statically
# /etc/netplan/02-static-config.yaml
network:
ethernets:
enp0s3:
addresses:
- {my static IP}
gateway4: {my gateway}
nameservers:
addresses:
- { some }
- { DNS servers }
dhcp4: false
version: 2
and one that very simply configures it to use DHCP
# /etc/netplan/03-dhcp-config.yaml
network:
ethernets:
enp0s3:
dhcp4: true
addresses: []
version: 2
I then wrote a couple shell scripts that renames the DHCP script to either 01
(if I wanted statics) or 03
(if I wanted DHCP), then called netplan generate
and netplan apply
.
Unfortunately, although the docs seem to imply that the addresses
mapping from 03-dhcp-config.yaml
should override 02-static-config.yaml
:
Lexicographically later files (regardless of in which directory they are) amend (new mapping keys) or override (same mapping keys) previous ones. ed: emphasis mine.
what I'm actually seeing is that both addresses bind to the same interface.
username@machine:~$ ip address show enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:6d:2c:d6 brd ff:ff:ff:ff:ff:ff
inet {my static IP} brd {a bridge} scope global enp0s3
valid_lft forever preferred_lft forever
inet {a DHCP address} brd {and associate bridge} scope global secondary dynamic enp0s3
valid_lft 691170sec preferred_lft 691170sec
inet6 fe80::a00:27ff:fe6d:2cd6/64 scope link
valid_lft forever preferred_lft forever
How can I make 03-dhcp-config.yaml
override 02-static-config.yaml
? Or alternatively: how can I disable 02-static-config.yaml
quickly and easily?