• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to create LXC container using lxcbr0 and virbr0 in CentOS/RHEL

by admin

Question: How to create an lxc container using lxcbr0 and virbr0 network interfaces?

LXC uses the virtualization management service to support network bridging for containers, libvirtd uses bridge network virbr0 and lxc-net.service uses bridge of lxcbr0. To start virbr0 bridge start libvirt service and create a container using network.link as virbr0:

virbr0: flags=4163 mtu 1500
inet 192.168.122.x netmask 255.255.255.0 broadcast 192.168.1xx.2xx
ether 52:54:00:be:71:21 txqueuelen 0 (Ethernet)
lxcbr0: flags=4163 mtu 1500
inet 10.220.239.1 netmask 255.255.255.0 broadcast 0.0.0.0
inet6 fe80::fc37:c0ff:fe01:78d7 prefixlen 64 scopeid 0x20
# cat /container/ol6ctr4/config
# Template used to create this container: /usr/share/lxc/templates/lxc-oracle
# Parameters passed to the template:
# For additional config options, please look at lxc.container.conf(5)
lxc.network.type = veth
lxc.network.link = virbr0

Container:

# ip addr
11: eth0@if12:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
inet 192.168.122.xx/24 brd 192.168.122.255 scope global dynamic eth0

To start the lxcbr0 bridge, start the lxc-net service and create a container using network.link as lxcbr0. The following then verifies that the container got the IP address assigned from the lxcbr0 address range.

# cat /container/ol5ctr1/config
# Template used to create this container: /usr/share/lxc/templates/lxc-oracle
# Parameters passed to the template: --release=5.latest -a x86_64 --baseurl=http://yum.oracle.com/repo/OracleLinux/OL5/latest/x86_64
# For additional config options, please look at lxc.container.conf(5)
lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:52:59:7d
lxc.rootfs = /container/ol5ctr1/rootfs
# Common configuration
lxc.include = /usr/share/lxc/config/oracle.common.conf
# Container configuration for Oracle Linux 5.latest
lxc.arch = x86_64
lxc.utsname = ol5ctr1
lxc.cap.drop = sys_resource
lxc.cap.drop = setfcap setpcap
lxc.autodev = 0
# Networking

lxc.network.name = eth0
lxc.network.mtu = 1500
# ifconfig lxcbr0
lxcbr0: flags=4163 mtu 1500
inet 10.112.62.XX netmask 255.255.255.0 broadcast 0.0.0.0

Container:

# ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:3E:52:59:7D
inet addr:10.112.62.xx Bcast:10.112.62.xxx Mask:255.255.255.0

Filed Under: CentOS/RHEL 6, CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. RPM : package installation Error : cpio: read failed
  2. How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  3. How to use execl (example included)
  4. Understanding The sysfs File System (/sys) in Linux
  5. touch Command Examples in Linux
  6. virt-manager: command not found
  7. How to Ignore/Disable Specific auditd Logging Entries
  8. CentOS / RHEL 7 : How to Install GUI
  9. iftop: command not found
  10. lvm Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • pw-cat Command Examples in Linux
  • pvs: command not found
  • pulseaudio: command not found
  • pulseaudio Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright