2

I have an LXC OS container (CentOS 7) configured via libvirt (CentOS 7):

<domain type='lxc'>
  <name>lxc-test1.example.com</name>
  <uuid>5a715193-55ef-49d7-a4f6-ac5c27bce838</uuid>
  <memory unit='KiB'>2097152</memory>
  <currentMemory unit='KiB'>2097152</currentMemory>
  <vcpu placement='static'>4</vcpu>
  <os>
    <type arch='x86_64'>exe</type>
    <init>/sbin/init</init>
  </os>
  <features>
    <privnet/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/libexec/libvirt_lxc</emulator>
    <filesystem type='mount' accessmode='passthrough'>
      <source dir='/var/lib/libvirt/filesystems/lxc-test1.example.com'/>
      <target dir='/'/>
    </filesystem>
    <interface type='bridge'>
      <mac address='00:16:3e:c3:6c:78'/>
      <source bridge='br_v123'/>
    </interface>
    <console type='pty'>
      <target type='lxc' port='0'/>
    </console>
  </devices>
</domain>

When the container starts, it does not setup its network appropriately as defined in its local /etc/sysconfig/network-scripts/ifcfg-eth0

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=10.2.0.1
PREFIX=24
GATEWAY=10.2.0.254
DNS1=10.0.0.18
DNS2=10.0.0.19

However, if I ifdown eth0 && ifup eth0 within the container it obtains the desired configuration.

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
34: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:16:3e:c3:6c:78 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::216:3eff:fec3:6c78/64 scope link 
       valid_lft forever preferred_lft forever
 # ifdown eth0 && ifup eth0
 Device 'eth0' successfully disconnected.
 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/1)
 # ip addr
 34: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
     link/ether 00:16:3e:c3:6c:78 brd ff:ff:ff:ff:ff:ff
     inet 10.2.0.1/24 brd 10.47.34.255 scope global eth0
        valid_lft forever preferred_lft forever
     inet6 fe80::216:3eff:fec3:6c78/64 scope link 
        valid_lft forever preferred_lft forever

# ping -c 1 10.0.2.254
PING 10.0.2.254 (10.0.2.254) 56(84) bytes of data.
64 bytes from 10.0.2.254: icmp_seq=1 ttl=255 time=0.453 ms

--- 10.0.2.254 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.453/0.453/0.453/0.000 ms

How can I make libvirt start the container's network correctly?

1
  • Interesting. I've seen KVM VMs do this as well, intermittently. Oct 1, 2015 at 1:57

1 Answer 1

-2
systemctl disable NetworkManager
systemctl enable network
2
  • Welcome to Server Fault! Please consider reading How do I write a good Answer? in our help center and then revise the Answer. Your Commands could technically be a solution (or not) but some explanation is welcome. Thanks in advance.
    – HBruijn
    Oct 1, 2015 at 8:23
  • network is already enabled, as per default. Disabling NetworkManager does not seem to help.
    – 84104
    Oct 1, 2015 at 18:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .