I wanna create a new nic eth1 of my container, and I use lxc config device add r1 eth1 nic nictype=bridged parent=R2R3
the eth1 can be seen in the container by ifconfig
BUT it doesn’t have an IPv4 address
By the way, I create the R2R3 network by lxc network create R1R2 ipv6.address=none ipv4.address=23.23.23.1/24 ipv4.nat=true
on the host, you will see whether the network is managed (by LXD) or unmanaged.
If it is managed (by LXD), then it is LXD’s fault that the container is not getting an IP address.
If it is unmanaged, then it is your task to setup a DHCP server on that interface to give DHCP leases to the containers.
Could you post your profile file? or you can copy your default profile with another name for test purpose and in there just add eth1 device like eth0.
And you will also define the eth1 interface in the container as well.
The default LXD images only have DHCP configured inside the container on eth0. So if you’re adding a new NIC as eth1, then you’ll also need to update the container’s network config to do DHCP on that interface.
The use of that command is to assign a static DHCP lease in the LXD DHCP server for managed networks such that when the container starts and requests a DHCP address using its interface’s MAC address it always gets the same statically leased address.
lxc profile copy default test, here default copied to the test profile. Then you can edit the test profile as you imagine, you can copy something like that for the eth1 device to the test profile as you wish. Even you can arrange another network with different values.
devices:
eth0:
nictype: bridged
parent: lxdbr0
type: nic
eth1:
nictype: bridged
parent: lxdbr0
type: nic
Regards.