0

I'm setting up an LXC container on an openSuSE 42.1 host.

The host has full Internet access but the container hasn't. The container can ping the host, but nothing else on the LAN or Internet.

I think the issue could be how the bridge is configured on the host, but I can't see how to resolve this.

The host has eth0 and br0. br0 has been assigned a static IP Address etc.

In YAST I have the Default IPv4 Gateway as 192.168.2.1 and the Device as br0

Here is the network detail for the host

route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway.localdo 0.0.0.0         UG    0      0        0 br0
192.168.2.0    *               255.255.255.0   U     0      0        0 br0

netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.2.1    0.0.0.0         UG        0 0          0 br0
192.168.2.0    0.0.0.0         255.255.255.0   U         0 0          0 br0

ifconfig -a
br0       Link encap:Ethernet  HWaddr 08:00:27:E5:C3:27  
          inet addr:192.168.2.197  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fee5:c327/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:266675 errors:0 dropped:0 overruns:0 frame:0
          TX packets:60989 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1391858642 (1327.3 Mb)  TX bytes:4049229 (3.8 Mb)

eth0      Link encap:Ethernet  HWaddr 08:00:27:E5:C3:27  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1259099 errors:0 dropped:5 overruns:0 frame:0
          TX packets:220712 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1449135910 (1382.0 Mb)  TX bytes:51279387 (48.9 Mb)

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:65536  Metric:1
          RX packets:11033 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11033 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:968389 (945.6 Kb)  TX bytes:968389 (945.6 Kb)

vethYW604 Link encap:Ethernet  HWaddr FE:A8:5F:48:80:7E  
          inet6 addr: fe80::fca8:5fff:fe48:807e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:251 errors:0 dropped:0 overruns:0 frame:0
          TX packets:120979 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:75398 (73.6 Kb)  TX bytes:71086180 (67.7 Mb)

gateway.localdomain resolves to 192.168.2.1

The containers config file is:

lxc.network.type = empty
lxc.rootfs = /var/lib/lxc/TestLXC/rootfs
lxc.include = /usr/share/lxc/config/opensuse.common.conf
lxc.arch = x86_64
lxc.utsname = TestLXC
lxc.mount.auto = cgroup:mixed proc:mixed sys:mixed

lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.name = eth0

lxc.network.hwaddr = 08:00:27:e5:c3:29
lxc.aa_allow_incomplete = 1

lxc.network.ipv4 = 192.168.2.221/24
lxc.network.ipv4.gateway = 192.168.2.197

and it's network details are:

route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.2.197  0.0.0.0         UG    0      0        0 eth0
192.168.2.0    *               255.255.255.0   U     0      0        0 eth0

netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.2.197  0.0.0.0         UG        0 0          0 eth0
192.168.2.0    0.0.0.0         255.255.255.0   U         0 0          0 eth0

ifconfig -a
eth0      Link encap:Ethernet  HWaddr 08:00:27:E5:C3:29  
          inet addr:192.168.2.221  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fee5:c329/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:133802 errors:0 dropped:0 overruns:0 frame:0
          TX packets:280 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:78627055 (74.9 Mb)  TX bytes:82972 (81.0 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:65536  Metric:1
          RX packets:26 errors:0 dropped:0 overruns:0 frame:0
          TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2152 (2.1 Kb)  TX bytes:2152 (2.1 Kb)

Can anyone advise how I can get my LXC container to have full network and Internet access.

Thanks

1 Answer 1

1

You configured bridge, which means host and container are on the same subnet. Therefore the container should use the same gateway as the host, but you did set the host's IP as default gateway. Set it to 192.168.2.1 instead

3
  • Thanks I've changed the gateway on the container and restarted it. I have the same issue. I can ping the host, but nothing else. Any other ideas ?
    – Tom
    Commented Aug 18, 2017 at 9:26
  • Can you ping the host from the container? Also set lxc.network.type = veth instead of "empty"
    – haary
    Commented Aug 18, 2017 at 11:18
  • Yes I can ping the host from the container. I actually have lxc.network.type twice in my config file (not sure why) the second entry is veth
    – Tom
    Commented Aug 18, 2017 at 12:09

You must log in to answer this question.

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