With CentOS 6 and LXC, "ifconfig" is unable to see network interface (but busybox "ifconfig" works fine)

Posted by larsks on Server Fault See other posts from Server Fault or by larsks
Published on 2011-10-28T00:32:36Z Indexed on 2012/07/07 9:18 UTC
Read the original article Hit count: 325

I've just started working with LXC under CentOS 6 (via the libvirt adapter). If I create an LXC container, I'm unable to see any network interfaces when using the native system tools:

# ifconfig -a
#

The behavior is very odd; specifying an interface by names yields neither the expected output nor an error message. This is true even for clearly invalid interface names, like this:

# ifconfig foo
#

The ip command exhibits the same behavior.

On the other hand, if I use "ifconfig" provided by busybox, everything works as expected:

# busybox ifconfig -a

eth0      Link encap:Ethernet  HWaddr 52:54:00:E0:12:C8  
          inet6 addr: fe80::5054:ff:fee0:12c8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:268 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:17814 (17.3 KiB)  TX bytes:552 (552.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

So...what does busybox know that the native tools don't? The libvirt config for this environment is pretty standard; the network definition looks like this:

<interface type='network'>
  <mac address='52:54:00:e0:12:c8'/>
  <source network='default'/>
  <target dev='veth0'/>
</interface>

The full configuration is here if you think it might help.

I'm running:

  • lxc-0.7.2-2.el6.x86_64
  • kernel-2.6.32-71.29.1.el6.x86_64

EDIT

Weirder and weirder...it's a display issue, not a functionality issue. I can see the output of ifconfig if I pipe it into anything, so for example:

# ifconfig eth0 | cat
eth0      Link encap:Ethernet  HWaddr 52:54:00:E0:12:C8  
          inet addr:192.168.10.10  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fee0:12c8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:573 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:37914 (37.0 KiB)  TX bytes:552 (552.0 b)

And in fact even when not piping the output, strace shows that ifconfig is in fact writing the output to file descriptor 1 (aka stdout), so it's not clear why no output is actually showing up. This could be either an LXC or a virsh issue, I guess.

© Server Fault or respective owner

Related posts about linux

Related posts about networking