It is not advised to overwrite the .yaml file cloud-init created. Instead, we could only list the additional IPs like so:
network:
version: 2
ethernets:
eth0:
addresses:
- 10.10.10.2/24
This works because netplan generates config by merging YAML files, and the rules are that sequence values are concatenated, with the new values appended to the old list. See netplan-generate(8)
for details.
Alternatively, you could create /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
as follows to prevent cloud-init from changing network configuration again:
network:
config: disabled
However, this approach would prevent the image to be reused for another instance.