Using a LXD macvlan Network : "Error: Failed to start device "eth0": Parent device 'enp2s0' doesn't exist"i

Hello ,
i just trying to make some containers to access from network and finded this tutorial :

but facing error when launch container
Error: Failed to start device “eth0”: Parent device ‘enp2s0’ doesn’t exist

this is fresh installation ubuntu-22.04.3-live-server-amd64

$ lxd init --minimal
$ lxc profile copy default macvlan-profile
$ lxc profile device remove macvlan-profile eth0
Device eth0 removed from macvlan-profile
$ lxc profile device add macvlan-profile eth0 nic nictype=macvlan parent=enp2s0
Device eth0 added to macvlan-profile
$ lxc launch images:ubuntu/22.04 cPanel --profile macvlan-profile
Creating cPanel
Starting cPanel                           
Error: Failed to start device "eth0": Parent device 'enp2s0' doesn't exist
Try `lxc info --show-log local:cPanel` for more info
$ lxc info --show-log local:cPanel
Name: cPanel
Status: STOPPED
Type: container
Architecture: x86_64
Created: 2023/10/09 19:48 UTC

Log:



$ ifconfig 
enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.1  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::223:24ff:fe12:d147  prefixlen 64  scopeid 0x20<link>
        ether 00:23:24:12:d1:47  txqueuelen 1000  (Ethernet)
        RX packets 93643  bytes 136594271 (136.5 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 46551  bytes 3349163 (3.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  memory 0xf0500000-f0520000  

enp0s25.1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::223:24ff:fe12:d147  prefixlen 64  scopeid 0x20<link>
        ether 00:23:24:12:d1:47  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 75  bytes 20894 (20.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 174  bytes 15421 (15.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 174  bytes 15421 (15.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lxdbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 10.134.3.1  netmask 255.255.255.0  broadcast 0.0.0.0
        inet6 fd42:2f46:32ae:ba6a::1  prefixlen 64  scopeid 0x0<global>
        ether 00:16:3e:b2:76:4b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
$ lxc profile show default
config: {}
description: Default LXD profile
devices:
  eth0:
    name: eth0
    network: lxdbr0
    type: nic
  root:
    path: /
    pool: default
    type: disk
name: default
used_by: []


$ lxc network show lxdbr0
config:
  ipv4.address: 10.134.3.1/24
  ipv4.nat: "true"
  ipv6.address: fd42:2f46:32ae:ba6a::1/64
  ipv6.nat: "true"
description: ""
name: lxdbr0
type: bridge
used_by:
- /1.0/profiles/default
managed: true
status: Created
locations:
- none

that’s all

So you’ve got it configured to use your host enp2s0 but don’t have such a device, error looks accurate. Looks like you want enp0s25 instead.

1 Like

Thanks so much.

now how i can set static IP for each container

By using whatever the network configuration mechanism is for the distro you’re using.
With macvlan, LXD has no control over IP allocation, so it must be done inside the instance.

1 Like

now container and lxd server cant ping each other :smiling_face_with_tear:
but can ping other containers

That’s normal behavior for macvlan.

Thanks friends for the discussion. I used to use the default FanNetworking and it worked extremely fine without my worrying about it. When I came to Incus, the situation seems different. Now I use the following steps to create or copy an instance with the desired profile, and position it on the the correct cluster node (with the --target switch or move it later).

  1. Create a profile for each node of the cluster
    1.1 Copy the default profile to create a new profile
incus profile copy default macvlan-profile-hpz2mini

1.2 Modify the eth0 of this new profile as indicated by @mohamed.daif (Note: eno1 is the nic of cluster node hpz2mini.)

incus profile device remove macvlan-profile-hpz2mini eth0
incus profile device add macvlan-profile-hpz2mini eth0 nic nictype=macvlan parent=eno1
  1. Create or Copy to make a new instance based on the desired profile
incus copy u2204-template jupyterhub01 --profile macvlan-profile-hpz2mini
  1. If the newly create instance is placed on the wrong cluster node and cannot be stared, move it to the node corresponding to the profile of this instance:
incus move instance_name --target cluster_node_name

This solution might not be the best. However, it works and solved the problem raised by @mohamed.daif, which I encountered after migrating from LXD to Incus.