Container created with wrong hwaddr with nic type ipvlan

Hi there,

In an attempt to expose my container with a public floating IP from OVH, I successfully managed to make it work with macvlan nic type but failed with ipvlan type. This is new to me, maybe what I am just plain wrong. The IP is assigned to the correct interface but the MAC address I use on creation is not honored, with a random generated address instead.

Desired MAC address, xx:00:00:21:xx:0d:

lxc config device add \
  au-test-1 \
  eth0 nic \
  name=eth0 \
  mode=l2 \
  nictype=ipvlan \
  parent=ens5f0 \
  hwaddr=xx:00:00:21:xx:0d \
  ipv4.address=xx.187.xx.170/32 \
  ipv4.gateway=xx.178.xx.254

Created MAC address is different, xx:a9:fc:43:xx:b2:

lxc exec au-test-1 -- ip addr show eth0
324: eth0@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether xx:a9:fc:43:xx:b2 brd ff:ff:ff:ff:ff:ff
    inet xx.187.xx.170/32 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 xx::b4a9:fc00:xx:a4b2/64 scope link 
       valid_lft forever preferred_lft forever

I tried both l2 and l3s modes with similar results. Attempting to unset and set the eth0 hwaddr property from the container device has no effect.

I just read Simons Xenitellis article which states

Any containers with ipvlan will appear on the network to have the MAC address of the host.

And indeed, this MAC address posted above is the one of the host machine. This explain why I am not obtaining the provided MAC.

Before closing, maybe we could rephrase the doc. I got mislead when reading the introduction in nic: ipvlan

Sets up a new network device based on an existing one using the same MAC address but a different IP.

  1. “based on an existing one” deserve some clarification because it was not the case with me
  2. “using the same MAC address but” rephrase as “sharing the MAC address of the host machine but”

I could propose a PR for the later, but I am still confused with the former.

Yes a pr would be welcome. Thanks.

“Existing one” in this context means “based on existing host network interface”.

Yes it shares the mac address of the existing host interface (unlike macvlan nic type), but has a different ip address.