Lan Ip And lxdbr0 Ip

Hi Najib!

You can create a LXD profile with two entries about networking (macvlan, and bridged), then create a container using that profile.
Here is how to do that:

  1. I suppose you already have a profile according to https://blog.simos.info/how-to-make-your-lxd-container-get-ip-addresses-from-your-lan/ Let’s call that profile lanprofile.

  2. Copy that profile into a new name, let’s say, macbridge (macvlan and bridge).

    lxc profile copy lanprofile macbridge
    
  3. Add a new eth1 network interface for the lxdbr0 bridge.

    lxc profile device add macbridge eth1 nic nictype=bridged parent=lxdbr0
    
  4. By doing so, the macbridge profile will look like:

    devices:
      eth0:
        nictype: macvlan
        parent: enp3s0
        type: nic
    eth1:
      nictype: bridged
      parent: lxdbr0
      type: nic
    
  5. And now you can launch the container with

    lxc launch ubuntu:18.04 --profile macbridge mycontainer
    

When you get a shell in mycontainer, you will notice that eth1 did not get an IP address automatically. It’s up to you to make the configuration to get the IP address automatically. The manual way, anyway, is sudo dhclient eth1.