LXC Network Issue

This is my ubuntu-lxc VM.

root@ubuntu-lxc:/tmp# uname -a
Linux ubuntu-lxc 4.4.0-98-generic #121-Ubuntu SMP Tue Oct 10 14:24:03 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
root@ubuntu-lxc:/tmp#
root@ubuntu-lxc:/tmp# lxc --version
2.0.11
root@ubuntu-lxc:/tmp#
root@ubuntu-lxc:/tmp# ifconfig -a
enp0s3 Link encap:Ethernet HWaddr 08:00:27:0c:1c:97
inet addr:192.168.0.183 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe0c:1c97/64 Scope:Link
inet6 addr: 2601:204:c402:7660:a00:27ff:fe0c:1c97/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:32585 errors:0 dropped:0 overruns:0 frame:0
TX packets:8617 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2914066 (2.9 MB) TX bytes:1498265 (1.4 MB)

enp0s8 Link encap:Ethernet HWaddr 08:00:27:9c:90:00
inet addr:192.168.0.60 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe9c:9000/64 Scope:Link
inet6 addr: 2601:204:c402:7660:a00:27ff:fe9c:9000/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:181344 errors:0 dropped:0 overruns:0 frame:0
TX packets:40407 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:226896881 (226.8 MB) TX bytes:5098146 (5.0 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:261 errors:0 dropped:0 overruns:0 frame:0
TX packets:261 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:22117 (22.1 KB) TX bytes:22117 (22.1 KB)

lxcbr0 Link encap:Ethernet HWaddr 00:16:3e:00:00:00
inet addr:192.168.0.100 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 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:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

root@ubuntu-lxc:/tmp#

This is my 4 centos containers

root@ubuntu-lxc:/tmp# lxc-ls --fancy
NAME STATE AUTOSTART GROUPS IPV4 IPV6
centos10 RUNNING 0 - 192.168.0.89 -
centos7 RUNNING 0 - 192.168.0.96 -
centos8 RUNNING 0 - 192.168.0.4 -
centos9 RUNNING 0 - 192.168.0.54 -
root@ubuntu-lxc:/tmp#

This is one of centos details

root@ubuntu-lxc:/tmp# lxc-attach -n centos7
[root@centos7 tmp]# ifconfig -a
eth0 Link encap:Ethernet HWaddr FE:17:60:49:66:E9
inet addr:192.168.0.96 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::fc17:60ff:fe49:66e9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:55 errors:0 dropped:0 overruns:0 frame:0
TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6535 (6.3 KiB) TX bytes:1458 (1.4 KiB)

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:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
[root@centos7 tmp]#

Obviously, I can able to ping the localhost and centos7’s eth0

[root@centos7 tmp]# ping 192.168.0.96
PING 192.168.0.96 (192.168.0.96) 56(84) bytes of data.
64 bytes from 192.168.0.96: icmp_seq=1 ttl=64 time=0.111 ms
64 bytes from 192.168.0.96: icmp_seq=2 ttl=64 time=0.051 ms
^C
— 192.168.0.96 ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 1480ms
rtt min/avg/max/mdev = 0.051/0.081/0.111/0.030 ms
[root@centos7 tmp]#
[root@centos7 tmp]# ping 0
PING 0 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.034 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.043 ms
^C
— 0 ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 1922ms
rtt min/avg/max/mdev = 0.034/0.038/0.043/0.007 ms
[root@centos7 tmp]#

I can able to ping centos8 (another lxc)

[root@centos7 tmp]# ping 192.168.0.96
PING 192.168.0.96 (192.168.0.96) 56(84) bytes of data.
64 bytes from 192.168.0.96: icmp_seq=1 ttl=64 time=0.034 ms
64 bytes from 192.168.0.96: icmp_seq=2 ttl=64 time=0.035 ms
^C
— 192.168.0.96 ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 1664ms
rtt min/avg/max/mdev = 0.034/0.034/0.035/0.005 ms
[root@centos7 tmp]#

But I couldn’t connect to my dnsmasq server (.40)

root@centos7 tmp]#ping 192.168.0.40
PING 192.168.0.40 (192.168.0.40) 56(84) bytes of data.
From 192.168.0.96 icmp_seq=1 Destination Host Unreachable
From 192.168.0.96 icmp_seq=2 Destination Host Unreachable
From 192.168.0.96 icmp_seq=3 Destination Host Unreachable
^C
— 192.168.0.40 ping statistics —
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4610ms
pipe 3
[root@centos7 tmp]#

But I couldn’t connect to my dnsmasq server (.183) enp0s3 and enp0s8

[root@centos7 tmp]# ping 192.168.0.183
PING 192.168.0.183 (192.168.0.183) 56(84) bytes of data.
From 192.168.0.96 icmp_seq=1 Destination Host Unreachable
From 192.168.0.96 icmp_seq=2 Destination Host Unreachable
From 192.168.0.96 icmp_seq=3 Destination Host Unreachable
^C
— 192.168.0.183 ping statistics —
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4678ms
pipe 3
[root@centos7 tmp]#

[root@centos7 tmp]# ping 192.168.0.60
PING 192.168.0.60 (192.168.0.60) 56(84) bytes of data.
From 192.168.0.96 icmp_seq=1 Destination Host Unreachable
From 192.168.0.96 icmp_seq=2 Destination Host Unreachable
From 192.168.0.96 icmp_seq=3 Destination Host Unreachable
^C
— 192.168.0.60 ping statistics —
4 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3801ms
pipe 3
[root@centos7 tmp]#

Nor the Host Bridge connector lxcbr0

[root@centos7 tmp]# ping 192.168.0.100
PING 192.168.0.100 (192.168.0.100) 56(84) bytes of data.
^C
— 192.168.0.100 ping statistics —
3 packets transmitted, 0 received, 100% packet loss, time 2864ms

[root@centos7 tmp]#

or the internet

[root@centos7 tmp]# ping google.com
^C
[root@centos7 tmp]#

What might the problem ?

This is my host (ubuntu -c - (.183)) interface details :

root@ubuntu-lxc:/tmp# 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).

source /etc/network/interfaces.d/*

The loopback network interface

auto lo
iface lo inet loopback

The primary network interface

auto enp0s3
iface enp0s3 inet dhcp

The secondary network interface

auto enp0s8
iface enp0s8 inet static
address 192.168.0.60
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
root@ubuntu-lxc:/tmp#

and

root@ubuntu-lxc:/tmp# cat /etc/default/lxc-net

This file is auto-generated by lxc.postinst if it does not

exist. Customizations will not be overridden.

Leave USE_LXC_BRIDGE as “true” if you want to use lxcbr0 for your

containers. Set to “false” if you’ll use virbr0 or another existing

bridge, or mavlan to your host’s NIC.

USE_LXC_BRIDGE=“true”

If you change the LXC_BRIDGE to something other than lxcbr0, then

you will also need to update your /etc/lxc/default.conf as well as the

configuration (/var/lib/lxc//config) for any containers

already created using the default config to reflect the new bridge

name.

If you have the dnsmasq daemon installed, you’ll also have to update

/etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.

LXC_BRIDGE="lxcbr0"
LXC_ADDR="10.0.3.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.0.3.0/24"
LXC_DHCP_RANGE="10.0.3.2,10.0.3.254"
LXC_DHCP_MAX=“253”

Uncomment the next line if you’d like to use a conf-file for the lxcbr0

dnsmasq. For instance, you can use ‘dhcp-host=mail1,10.0.3.100’ to have

container ‘mail1’ always get ip address 10.0.3.100.

#LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf

Uncomment the next line if you want lxcbr0’s dnsmasq to resolve the .lxc

domain. You can then add "server=/lxc/10.0.3.1’ (or your actual $LXC_ADDR)

to your system dnsmasq configuration file (normally /etc/dnsmasq.conf,

or /etc/NetworkManager/dnsmasq.d/lxc.conf on systems that use NetworkManager).

Once these changes are made, restart the lxc-net and network-manager services.

‘container1.lxc’ will then resolve on your host.

#LXC_DOMAIN="lxc"
root@ubuntu-lxc:/tmp#

I know something wrong with my lxc-net.

Could you please direct me to right place/direction ?