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.