libvirt lxc CentOS 7 container eth0 keeps changing on boot

General support questions
Post Reply
wchao
Posts: 7
Joined: 2014/07/19 20:37:00

libvirt lxc CentOS 7 container eth0 keeps changing on boot

Post by wchao » 2014/07/19 20:55:01

I am running CentOS 7 and trying to create a libvirt LXC CentOS 7 container. I am able to create the CentOS 7 container and then boot into it fine. I then need to run:

Code: Select all

nmcli connection delete eth0
nmcli connection add type ethernet ifname eth0 con-name eth0
The network interface works fine after that. When I shut down the container and start it back up, there are two eth0 connections, and only one of them is linked to the eth0 device. Unfortunately, the connection profile that is linked to the eth0 device is a new connection profile, not the one I created in the previous session inside the container. If I run

Code: Select all

nmcli connection delete eth0
, both eth0 connection profiles will be deleted. Then I can run

Code: Select all

nmcli connection add type ethernet ifname eth0 con-name eth0
and networking functions again in the container. I also noticed the MAC address of the eth0 device inside the container changes every time the container is booted up. Additionally, I noticed that running

Code: Select all

udevadm info /sys/class/net/eth0
reveals a different IFINDEX each time the container boots.

Here is what I am using for the interface block in the libvirt XML configuration for the domain:

Code: Select all

    <interface type='bridge'>
      <mac address='52:54:00:df:d0:ae'/>
      <source bridge='br0'/>
    </interface>
Here is how I created the libvirt LXC domain with CentOS 7:

Code: Select all

yum -y --installroot=/var/lib/libvirt/filesystems/mycentos7 --releasever=7 group install "Virtualization Host"
echo "pts/0" >> /var/lib/libvirt/filesystems/mycentos7/etc/securetty
chroot /var/lib/libvirt/filesystems/mycentos7 /bin/passwd root
virt-install --connect lxc:// --name mycentos7 --ram 1024 --network="bridge=br0" --filesystem /var/lib/libvirt/filesystems/mycentos7,/
Does anyone know how I can get the Ethernet interface inside the container to have a stable MAC address and bind to the same connection profile in order to avoid the problem of a new connection profile being generated at each boot?

monzer4819
Posts: 3
Joined: 2014/07/21 15:43:51

Re: libvirt lxc CentOS 7 container eth0 keeps changing on bo

Post by monzer4819 » 2014/07/21 15:52:50

I noticed this problem too. My own workaround was to take NetworkManager out of the equation and just use the old style network scripts. I was kinda annoyed because it's not the recommended way, but it works and that's what I needed.

Incidently I had the same non-persistent mac address problem on the host when trying to create a bridge with NetworkManager and ended up using network scripts there too.

On the host and guest

Code: Select all

systemctl disable NetworkManager

Code: Select all

cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=aa:bb:cc:dd:ee:ff
TYPE=Ethernet
BOOTPROTO=none
NAME="eth0"
ONBOOT=yes
NM_CONTROLLED=no
BRIDGE=br10

Desintegr
Posts: 1
Joined: 2014/08/01 07:34:54

Re: libvirt lxc CentOS 7 container eth0 keeps changing on bo

Post by Desintegr » 2014/08/01 07:37:16

Hi.

I have reported this bug on the CentOS bugtracker : http://bugs.centos.org/view.php?id=7435
I have also reported it upstream on the RedHat bugtracker : https://bugzilla.redhat.com/show_bug.cgi?id=1124721
The RedHat bug is marked as private, I will report updates on the CentOS bug.

User avatar
toracat
Site Admin
Posts: 7490
Joined: 2006/09/03 16:37:24
Location: California, US
Contact:

Re: libvirt lxc CentOS 7 container eth0 keeps changing on bo

Post by toracat » 2014/08/01 10:10:34

Thank you for submitting the bug reports. Yes, please keep us posted.
CentOS Forum FAQ

wchao
Posts: 7
Joined: 2014/07/19 20:37:00

Re: libvirt lxc CentOS 7 container eth0 keeps changing on bo

Post by wchao » 2014/08/01 22:46:14

NetworkManager has fewer problems running in an LXC container managed by LXC (as opposed to libvirt). When I create a CentOS 7 container using the lxc tools, my Ethernet interface inside the container is stable.

I think the changing Ethernet interface is caused by a bad interaction between libvirt and NetworkManager.

wchao
Posts: 7
Joined: 2014/07/19 20:37:00

Re: libvirt lxc CentOS 7 container eth0 keeps changing on bo

Post by wchao » 2014/08/02 12:49:18

To further add to my comment about NetworkManager behaving better under LXC rather than libvirt LXC, I should clarify that under LXC, there are still some problems. Notably, an Ethernet interface using DHCP is stable across multiple boots, but if I configure a static IP address on the Ethernet interface rather than DHCP, the Ethernet interface then displays the behavior I mentioned in my previous posts in which every boot generates a new Ethernet interface with a random MAC address. So, I can get Ethernet networking stable across boots in LXC using DHCP, but not static IP addressing.

In libvirt LXC, the Ethernet networking is not stable across boots using either DHCP or static IP addressing.

Keegoid
Posts: 1
Joined: 2014/08/06 08:26:43

Re: libvirt lxc CentOS 7 container eth0 keeps changing on bo

Post by Keegoid » 2014/08/06 08:48:43

I'm using CentOS 7.0 x86_64 installed with the DVD image using the GNOME Desktop option. I installed CentOS 7 to a flash drive and am booting to it via a USB port on my Lenovo ThinkPad.

I am experiencing the same problem only it's with the wireless connection. A new ifcfg-Auto_SSID-X file is created on each reboot and I have to enter the wireless password each time before it will connect. This causes Dropbox to freeze and it will only sync if I force close it and restart it after the wireless connection has been established. NetworkManager is started and enabled. Also, files to store the wireless passphrase called keys-Auto_SSID-X are created again with each boot.

This has happened from a fresh install without any changes or updates and continues to happen after yum update. Everything else works well and thank you for firewalld! It's so much easier for me to use than iptables. That's a step in the right direction.

Here is the config file that keeps getting created:

Code: Select all

ESSID="panda_91:66"
MODE=Managed
KEY_MGMT=WPA-PSK
TYPE=Wireless
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME="Auto panda_91:66"
UUID=45d7aa5e-06f5-491c-9f9e-97417f1e78a4
ONBOOT=yes
HWADDR=74:E5:0B:85:EB:9E
SECURITYMODE=open
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
Here's a look at the directory:

Code: Select all

ifcfg-Auto_panda_91:66    ifdown-ppp       ifup-Team
ifcfg-Auto_panda_91:66-1  ifdown-routes    ifup-TeamPort
ifcfg-Auto_panda_91:66-2  ifdown-sit       ifup-tunnel
ifcfg-Auto_panda_91:66-3  ifdown-Team      ifup-wireless
ifcfg-Auto_panda_91:66-4  ifdown-TeamPort  init.ipv6-global
ifcfg-Auto_panda_91:66-5  ifdown-tunnel    keys-Auto_panda_91:66
ifcfg-Auto_panda_91:66-6  ifup             keys-Auto_panda_91:66-1
ifcfg-Auto_panda_91:66-7  ifup-aliases     keys-Auto_panda_91:66-2
ifcfg-Auto_panda_91:66-8  ifup-bnep        keys-Auto_panda_91:66-3
ifcfg-Auto_panda_91:66-9  ifup-eth         keys-Auto_panda_91:66-4
ifcfg-enp0s25             ifup-ippp        keys-Auto_panda_91:66-5
ifcfg-lo                  ifup-ipv6        keys-Auto_panda_91:66-6
ifdown                    ifup-isdn        keys-Auto_panda_91:66-7
ifdown-bnep               ifup-plip        keys-Auto_panda_91:66-8
ifdown-eth                ifup-plusb       keys-Auto_panda_91:66-9
ifdown-ippp               ifup-post        network-functions
ifdown-ipv6               ifup-ppp         network-functions-ipv6
ifdown-isdn               ifup-routes
ifdown-post               ifup-sit

Post Reply