Setting up LXC containers with an unmanaged NAT bridge

So, I want to some custom stuff for my home network. To do these things I need a NAT Bridge, a DNS server and a DHCP Server. I want to run these on LXC but thus far I have been unable to do so, and I’m out of ideas on how to do it. I’ve been searching all over google for an answer, but I can’t seem to find it.

In any case I know you can set up a bridge with lxc network create and that basically sets up a dns server and dhcp server with dnsmasq.

I used netplan to configure myself a bridge like this:

network:
  version: 2
  renderer: networkd
  bridges:
    vbr0:
      addresses:
        - 172.25.0.1/24

I’ve added a lxc container’s interface to my bridge by doing this: lxc config device add app eth0 nic nictype=bridged parent=vbr0 name=eth0

Then I try to add a static ip with this command: lxc config device set app eth0 ipv4.address 198.168.0.4

However, it doesn’t add any IPs to my container and just fails to do anything.

I’m not sure where to go from here or if lxc containers will only accept ips from managed bridges. I’m also not sure what to do with my iptables. I only want to allow devices hooked to my home network to access this lxc network.

I would appreciate it someone could help me.

EDIT: I’m using Ubuntu 20.04.

When connecting a bridged NIC to an unmanaged external bridge, the ipv4.address and ipv6.address settings don’t do anything, as normally they would configure a static allocation in LXD’s DHCP server.

However if you want your container to have a static IP then you can configure the container’s network config internally (as you would a ‘real’ server). As the bridged NIC type just behaves as if the container is plugged into the external network switch.

I see, I will do that. Thanks for the help.