Wrong IP assignment

Hi,

My LXD dev server:
Ubuntu 20.04
LXD 4.3

My netplan:

network:
    version: 2
    renderer: networkd
    ethernets:
      enp0s25:
        dhcp4: no
    bridges:
        brvlan:
            dhcp4: no
            addresses:
            - 192.168.10.11/24
            gateway4: 192.168.10.1
            nameservers:
                addresses:
                - 192.168.10.1
            interfaces:
            - enp0s25

I create a lanprofile profile

config: {}
description: conf for eth on lan dhcp
devices:
  eth0:
    nictype: bridged
    parent: lxdbr0
    type: nic
  eth1:
    nictype: bridged
    parent: brvlan
    type: nic
  root:
    path: /
    pool: data
    type: disk
name: lanprofile

I use Terraform to create lxd container. But same problem when I create manually.

lxc launch ubuntu:focal -p lanprofile

Result, my lxc list:

+----------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| novel-moose    | RUNNING | 192.168.10.75 (eth0)  | fd42:ec75:4e34:1f56:216:3eff:fe0a:6e27 (eth1) | CONTAINER | 0         |
+----------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+

This is strange.

  • No two Interfaces in IPv4
  • I didn’t request IPv6 for eth1

I need to manually change netplan in container by:

network:
    version: 2
    ethernets:
        eth0:
            dhcp4: true
            dhcp6: false
        eth1:
            dhcp4: true
            dhcp6: false

And after restart container, my lxc list:

+----------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| novel-moose    | RUNNING | 192.168.10.75 (eth0)  | fd42:ec75:4e34:1f56:216:3eff:fe0a:6e27 (eth1) | CONTAINER | 0         |
|                |         | 10.180.203.56 (eth1)  |                                               |           |           |
+----------------+---------+-----------------------+-----------------------------------------------+-----------+-----------+

But I don’t understand.
Why eth0 have an ip like 192.168.x.x and eth1 10.180.x.x
In my lanprofile, it’s the reverse configuration!
And why IPv6 stay?

Is it possible to launched a new container with two interface up?

Another thing. When I started lxd server, my first netplan was with dhcp IP on brvlan, but each time I launched new container, IP from brvlan changes. strange again.

Can you help me?
Thanks

In your lanprofile try adding a name property to each device of eth0 and eth1 respectively, that will stop LXD guessing the name of the interface inside the container (note, the name of the device you have currently is just a friendly reference, it is not necessarily the interface name inside the container).

The LXD images are only configured by default to perform DHCP on the eth0 interface. So if you add another interface, it will not automatically do DHCP (although it will automatically try to configure IPv6 via SLAAC).

So try modifying the netplan config inside the container to do DHCP on eth1 too.

Thanks a lot!

I did not know that needed to add name in properties in add of device.

It’s works.

Now I needed to find solution to automate new netplan.

Thanks again!