Local DNS using projects on a shared network with same container name

I’ve been trying to figure out how the local DNS server works with projects and containers with the same name when using the same bridged network. What I’m looking to achieve is have the containers separated into projects and stop conflicts from occurring when the same container name is used.

A basic example of what I’ve currently tried:

lxc launch images:ubuntu/22.04 c1
lxc launch images:ubuntu/22.04 c2
lxc project create p1 -c features.images=false -c features.profiles=false -c features.storage.volumes=false
lxc project switch p1
lxc launch images:ubuntu/22.04 c1
lxc launch images:ubuntu/22.04 c2
lxc exec c2 -- resolvectl query c1.lxd
lxc project switch default
lxc exec c2 -- resolvectl query c1.lxd

It seems that regardless of the project, the local DNS server will return only one of the records for matched names between projects. Is there any way to alter the records returned by the local DNS server? Ideally at project level? I’d hoped that prefixing of the project to the container name might exist as a configuration option but I’ve not found much on this subject.

Is there a better way to handle this?

Any advise would be greatly appreciated

This is unfortunately a limitation of the bridge network type because it does not support name spacing the instance DNS names when used from multiple projects.

See a related issue here Perform case insensitive match when checking for duplicate instance names at create time · Issue #10797 · lxc/lxd · GitHub

There are several ways to avoid the issue:

  1. Use different instance names in projects.
  2. Create a separate managed network for each project (and optionally use the project’s restricted.networks.access feature to prevent instances from using networks that aren’t assigned to the project).
  3. Use ovn network type, which allows for networks to be created inside a project (effectively the same as option 2 without needing to create the network outside of the project).