Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've got one LXC container that works just fine, but a 2nd one now is mis-behaving.

I've configured a static route for it, but it just won't define a gateway after sudo services networking restart or after a reboot now, or lxc-restart ..., same for the DNS servers. Just the IP gets set (which is defined in the LXC containers config file).

It can ping the default gateway (10.1.0.1) just fine, but just doesn't set the default gateway route or nameservers.

davidparks21@WebApp:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
 address 10.1.3.10
 netmask 255.255.0.0
 broadcast 10.1.255.255
 gateway 10.1.0.1
 dns-nameservers 8.8.8.8
 dns-nameservers 8.8.4.4

davidparks21@WebApp:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.1.0.0        *               255.255.0.0     U     0      0        0 eth0

lxc.network.type=veth
lxc.network.name=eth0
lxc.network.link=br0
lxc.network.ipv4 = 10.1.3.10/16
lxc.network.flags=up
lxc.rootfs = /var/lib/lxc/WebApp/rootfs
lxc.utsname = prodweb1

root@WebApp:/var/log# ifdown eth0 && ifup eth0
ifdown: interface eth0 not configured
RTNETLINK answers: File exists
Failed to bring up eth0.

Note: On the other LXC container that does work, this command succeeds.


Adding this note:

root@WebApp:/var/log# ethtool eth0
Settings for eth0:
        Supported ports: [ ]
        Supported link modes:   Not reported
        Supported pause frame use: No
        Supports auto-negotiation: No
        Advertised link modes:  Not reported
        Advertised pause frame use: No
        Advertised auto-negotiation: No
        Speed: 10000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: off
        MDI-X: Unknown
        Link detected: yes

I think the question should really be, "why isn't eth0 getting configured when I reboot or run service networking restart"


root@WebApp:/var/log# ls /run/network/
ifstate  ifup.lo
root@WebApp:/var/log# ifconfig
eth0      Link encap:Ethernet  HWaddr ee:1d:b6:c7:8d:3d
          inet addr:10.1.3.10  Bcast:10.1.255.255  Mask:255.255.0.0
          inet6 addr: fe80::ec1d:b6ff:fec7:8d3d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:196 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:70482 (70.4 KB)  TX bytes:1174 (1.1 KB)

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:48 errors:0 dropped:0 overruns:0 frame:0
          TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3840 (3.8 KB)  TX bytes:3840 (3.8 KB)
share|improve this question

2 Answers 2

up vote 6 down vote accepted

I've been working on this issue for a while now. I am running 12.04 LXC 0.7.5 on the host and a mixture of 12.04 and 11.04 in the containers.

I had zero success with editing: /run/networking/ifstate as it seems to not persist after a container is restarted.

I solved the problem by commenting out the following line of the containers config file:

lxc.network.ipv4 = 10.1.3.10/16

Another solution that worked for me was to install LXC 8.0 via backports. You'll first need to enable backports in /etc/apt/sources.list.

sudo apt-get install -t precise-backports lxc

LXC 8.0 allows for the containers config file to configure the default gateway.

lxc.network.ipv4.gateway = 10.1.0.1
share|improve this answer
    
very nice gateway option, thanks! –  brauliobo Jun 22 at 19:52

Based on some other research I found out that adding:

  eth0=eth0 

to:

  /run/networking/ifstate

fixed the problem, I was then able to bring it down and up and it configured things as expected.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.