Hi,
Is there a way to have consistent interface name between containers restart from the host’s point of view ?
For now, I have containers attached to a bridge (lxc network attach lxdbr0 lxc-test eth0) with fixed IP address on the bridge (lxc config device set lxc-test eth0 ipv4.address 192.168.220.7). This part works fine.
However, after the container is started, I get with either ifconfig or ip ad an interface name built like that : vethxxxx@ifNN on the host.
If I restart the container (lxc restart lxc-test), I will get a new interface name vethyyyy@ifMM
As asked on irc, here is the output of one of my container (lxc-test) expanded config :
I did as you suggested :
Changed host_name to veth-test in the container config. ip ad reports :
veth-test@if14: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master lxdbr0 state LOWERLAYERDOWN group default qlen 1000
link/ether f6:b8:fc:5c:0a:0d brd ff:ff:ff:ff:ff:ff link-netnsid 1
So, I restarted the container and now ip ad reports
veth-test@if16: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master lxdbr0 state UP group default qlen 1000
link/ether fe:85:81:53:3e:60 brd ff:ff:ff:ff:ff:ff link-netnsid 1
So, between restarts, the left part of the veth interface name is consistent between restarts. That’s half of the solution. The right part increases it’s digits by two after a restart.
To follow the documentation, I set the “name” key value to “eth0-test”. I expected that to set the “ifxx” part of the interface name, but it didn’t.
Maybe this issue has nothing to do with lxd after all but with the kernel itself or some piece of software that sets the veth name when building it at container startup… Just wondering.
Aside of this, I fixed the mac address, as you can see on the config I shared earlier. But, here again, you will see that the mac displayed has nothing to do with the one I chose.
From what I saw at a glance, this can not be addressed. The kernel is it’s own master on this part.
The context I wanted to have all the interface name consistent is that we monitor each container’s interface traffic with check_mk and a nagvis map (check_mk version 1.5.0p2 that we can’t upgrade at the moment).
On some production servers, I had the left hand side of the interface set per container (like here in this thread veth-name) and found a way to set up the nagvis map to use the interface description as name of the service (iirc, I did it monthes ago). But I figured out that after restarting either the server or any of the containers, the map was broken because it searches for the interface index (the digits set by the kernel after the letters if. That’s why I wanted to see if this part could be custom… And it seems not.