LXD Containers with "Fake" IPs?

First off I should preface this by saying my knowledge of containers and networking is fairly limited. I’m trying to build a container for a legacy piece of software. When this software installs, it attempts to configure 13 IP addresses in the range How would I achieve having the container see its IPs in that form but have these IPs accessible from the container’s host under dynamically assigned IPs on the network device’s subnet?

You can create a managed bridge (separate from the default lxdbr0 bridge) with a specific subnet, and ensuring that the LXD host doesn’t take the address:

lxc network create foo ipv4.address=

Then launch a new instance that connects to that network, optionally with the -d flag that will create DHCP assignment so that the instance will always be assigned address. Its then free to use additional addresses inside the container as needed.

lxc launch images:ubuntu/jammy c1 -n foo -d eth0,ipv4.address=
1 Like