Candid + LXD 4.23 using an ipv4 only subnet

If you don’t want to connect your container directly to the external network (e.g. via an unmanaged bridge or a macvlan NIC connected to the external interface) then you can instead use the proxy device on the specific container to listen on an IP/port(s) of the LXD host and forward inbound connections into the container.

It can operate in NAT mode, which allows the source IP address to be maintained, but this requires that your container’s NIC device is configured with a static DHCP allocation on the managed parent bridge (likely lxdbr0).

E.g.

lxc network show lxdbr0 # Look for ipv4.address to indicate the subnet of the managed bridge
lxc config device override c1 eth0 ipv4.address=<n.n.n.n> # A free IP in the bridge's network subnet.
lxc config device add c1 myproxy proxy listen=tcp:<host_ip>:<host_port> connect=tcp:<container_ip>:<container_port> nat=true

Please see Using proxy device to forward network connections from host to container in NAT mode and Instance configuration - LXD documentation for more info.