質問 :lxcbr0 および virbr0 ネットワーク インターフェイスを使用して lxc コンテナーを作成する方法は?
LXC は仮想化管理サービスを使用してコンテナーのネットワーク ブリッジングをサポートし、libvirtd はブリッジ ネットワーク virbr0 を使用し、lxc-net.service は lxcbr0 のブリッジを使用します。 virbr0 ブリッジを開始するには、libvirt サービスを開始し、network.link を virbr0 として使用してコンテナーを作成します。
virbr0: flags=4163mtu 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=4163mtu 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
コンテナ:
# 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
lxcbr0 ブリッジを開始するには、lxc-net サービスを開始し、lxcbr0 として network.link を使用してコンテナーを作成します。次に、コンテナーが lxcbr0 アドレス範囲から割り当てられた IP アドレスを取得したことを確認します。
# 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=4163mtu 1500 inet 10.112.62.XX netmask 255.255.255.0 broadcast 0.0.0.0
コンテナ:
# 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