Static IP's, restoring from backup and ipv4.address subnets

I restored a container from a backup on a new host via
lxc image import c1.tar.gz --alias c1
and
lxc launch c1
which worked fine.

However, the only way to set the IP of the container on the new host to match the IP on the old host was to edit
ipv4.address
via
lxc network edit lxdbr0

I changed ipv4.address on the new host to match the subnet on the old host e.g. 10.217.238.1/24 and then the Set Static IP instructions via this post (Using static IPs with LXD) worked fine…

So my question is… Is editing ipv4.address via lxc network edit lxdbr0 to change the network subnet an ok way to go if you want to restore backups to a new host but ensure that the container has the same IP as the old host?

Yeah, the subnet used for lxdbr0 is selected randomly, so if you want your target host to match the source, changing it to match is the way to go.

1 Like

Great, thank you!