H4QFo

            ..Здесь мерилом работы
            считают усталость..

            Nautilus-Pompilius,
            "Скованные одной цепью", 1986, 3:10

Job (LXC host Centos 7.3, guests Zesty Centos 6.5):
---------------------------------------------------

Note: Centos 7.3 Virtual Box machine:

        NIC Bridged,
        Adapter: Intel Pro/1000 MT Desktop (8254OEM)
        Promiscuous Mode: Allow All

  $ cat /etc/redhat-release
  CentOS Linux release 7.3.1611 (Core)

  $ sudo -i

  # cat /etc/sysconfig/network-scripts/ifcfg-br0
  DEVICE=br0
  TYPE=Bridge
  BOOTPROTO=dhcp
  ONBOOT=yes

  # cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
  DEVICE=enp0s3
  ONBOOT=yes
  TYPE=Ethernet
  IPV6INIT=no
  USERCTL=no
  BRIDGE=br0

  # cat /etc/networks
  default 0.0.0.0
  loopback 127.0.0.0
  link-local 169.254.0.0 # ZEROCONFIG

  # service network restart

  # yum update
  # yum install libcap-devel libcgroup busybox \
                wget bridge-utils graphviz
  # yum groupinstall "Development tools"
  # git clone git://github.com/lxc/lxc
  # cd lxc/
  # sh autogen.sh
  # ./configure
  # make
  # make install
  # exit

  # lxc-checkconfig
  # lxc-create -n MyCentOSContainer1 \
               -t /usr/local/share/lxc/templates/lxc-centos
  # lxc-create -t download -n cn-01

  # chroot /usr/local/var/lib/lxc/MyCentOSContainer1/rootfs passwd

  # cat /usr/local/var/lib/lxc/MyCentOSContainer1/config | head
  ..
  lxc.network.type = veth
  lxc.network.link = br0

  # lxc-start -n MyCentOSContainer1
  # lxc-console -n MyCentOSContainer1
  ^a q

  # lxc-create -t download -n cn-01 # answers: ubuntu zesty amd64
  chroot /usr/local/var/lib/lxc/cn-01/rootfs bash
  ### adduser virtu, add him to group sudo ###
  zesty# adduser virtu
  zesty# cat /etc/group | grep ^sudo
  sudo:x:27:ubuntu,virtu
  zesty# exit

  # cat /usr/local/var/lib/lxc/cn-01/config | grep ^lxc.network.link
  lxc.network.link = br0
  # lxc-start -n cn-01
  # lxc-console -n cn-01
  ^a q

  # lxc-ls
  MyCentOSContainer1 cn-01
  # lxc-ls --active
  MyCentOSContainer1 cn-01
  # lxc-info -n MyCentOSContainer1
  Name:           MyCentOSContainer1
  State:          RUNNING
  PID:            21382
  IP:             192.168.1.150
  IP:             2001:7d0:83e2:9e80:fcbe:a2ff:fe8f:297a
  CPU use:        0.75 seconds
  BlkIO use:      8.00 KiB
  Memory use:     32.09 MiB
  KMem use:       0 bytes
  Link:           vethLK9CS5
   TX bytes:      12.31 KiB
   RX bytes:      149.05 KiB
   Total bytes:   161.37 KiB

  # lxc-stop -n MyCentOSContainer1
  # lxc-stop -n cn-01

Why?

  [root@CBOX ~]# uname -a
  Linux CBOX 3.10.0-514.16.1.el7.x86_64 #1 SMP Wed Apr 12 15:04:24
  UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  [root@CBOX ~]# lxc-start -n cn-01
  [root@CBOX ~]# lxc-console -n cn-01
  ..
  virtu@cn-01:~$ uname -a
  Linux cn-01 3.10.0-514.16.1.el7.x86_64 #1 SMP Wed Apr 12 15:04:24
  UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Virtual Bridge: Static IP

  # echo 1 > /proc/sys/net/ipv4/ip_forward
  # iptables -t nat -A POSTROUTING -o enp0s3 -j MASQUERADE
  # iptables-save | grep -i MASQ

Links:

  1. http://www.thegeekstuff.com/2016/01/install-lxc-linux-containers/
  2. http://www.thegeekstuff.com/2016/01/create-lxc-containers/
  3. https://serverfault.com/questions/612021/lxc-container-networking

Also used:

  1. http://www.linuxquestions.org/questions
     /linux-networking-3/ping-through-a-specific-interface-414246/
  2. https://www.cyberciti.biz/faq
        /how-to-create-bridge-interface-ubuntu-linux/
  3. https://serverfault.com/questions/612021/lxc-container-networking
  4. http://www.alexlinux.com/lxc-bridge-example-centos/
  5. https://sysadmincasts.com/episodes
     /24-introduction-to-containers-on-linux-using-lxc
  6. https://www.virtualmin.com/documentation/cloudmin/virtualization/lxc
  7. https://insights.ubuntu.com/2015/11/10
     /converting-eth0-to-br0-and-getting-all-your-lxc-or-lxd-onto-your-lan/
