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 ( 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

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

lxc.network.ipv4 =
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:  Bcast:  Mask:
          inet6 addr: fe80::ec1d:b6ff:fec7:8d3d/64 Scope:Link
          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:  Mask:
          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)
up vote 8 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 =

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 =
  • 1
    very nice gateway option, thanks! – brauliobo Jun 22 '14 at 19:52
  • ditto; gateway option fixed the problem for me too. – David Goodwin Feb 15 '17 at 14:36

Based on some other research I found out that adding:




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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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