“无法将‘veth87VSIJ’连接到网桥‘virbr0’:没有这样的设备”

“无法将‘veth87VSIJ’连接到网桥‘virbr0’:没有这样的设备”

我在虚拟机中使用 Fedora 20 并尝试学习使用容器。我已经创建了一个容器,但无法启动它。这是终端输出:

[root@localhost home]# lxc-start -n test
lxc-start: conf.c: instantiate_veth: 2978 failed to attach 'veth87VSIJ' to the bridge 'virbr0': No such device
lxc-start: conf.c: lxc_create_network: 3261 failed to create netdev
lxc-start: start.c: lxc_spawn: 826 failed to create the network
lxc-start: start.c: __lxc_start: 1080 failed to spawn 'test'
lxc-start: lxc_start.c: main: 342 The container failed to start.
lxc-start: lxc_start.c: main: 346 Additional information can be obtained by setting the --logfile and --logpriority options.
[root@localhost home]# 

答案1

确保 libvirtd 已安装并正在运行(通过 libvirt 软件包)。例如:

$ yum install -y libvirt
$ systemctl start libvirtd
$ brctl show
bridge name bridge id       STP enabled interfaces
virbr0      8000.fea2866efadb   yes     veth7ATCJK

答案2

  1. 更改您的网络 hwaddr (在配置容器文件上)
  2. 设置你的网桥的IP并进行弥补

http://febru.soluvas.com/2015/03/solved-failed-to-attach-bridge-virbr0.html

答案3

错误信息

lxc-start:conf.c:instantiate_veth:2978无法将“veth87VSIJ”附加到桥“virbr0”:没有这样的设备

清楚地表明您的系统上不存在桥接口。您可以使用以下命令检查当前可用的接口

如果配置

或者

ip链接

在当前情况下,因为您没有启用桥接,所以要知道的另一件事是 virbr0 通常与 xen 或 libvirtd 等可视化服务相关联。因此,您可以尝试的第一件事就是启动其中一个(在 fedora 20 中,我认为您正在使用 libvirtd)

sudo systemctl 启动 libvirtd

如果这个接口没有被激活,你可以简单地手动添加它,但我强烈建议不要这样做,以避免配置冲突。

我建议的更好的解决方案是完全使用不同的网桥,因为它还可以让您更好地控制它的配置。首先,您必须通过检查来确定 lxc-net 网桥名称的设置位置/usr/libexec/lxc/lxc-net

#!/bin/sh -

distrosysconfdir="/etc/sysconfig"
varrun="/run/lxc"
varlib="/var/lib"

# These can be overridden in /etc/sysconfig/lxc
#   or in /etc/sysconfig/lxc-net

USE_LXC_BRIDGE="true"
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"
LXC_DHCP_CONFILE=""
LXC_DOMAIN=""

LXC_IPV6_ADDR=""
LXC_IPV6_MASK=""
LXC_IPV6_NETWORK=""
LXC_IPV6_NAT="false"

[ ! -f $distrosysconfdir/lxc ] || . $distrosysconfdir/lxc

这将被覆盖/etc/lxc/default.conf

lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:xx:xx:xx

仅当 USE_LXC_BRIDGE="true" 时/etc/sysconfig/lxc(这里不是这种情况)

# LXC_AUTO - whether or not to start containers at boot
LXC_AUTO="true"

# BOOTGROUPS - What groups should start on bootup?
#   Comma separated list of groups.
#   Leading comma, trailing comma or embedded double
#   comma indicates when the NULL group should be run.
# Example (default): boot the onboot group first then the NULL group
BOOTGROUPS="onboot,"

# SHUTDOWNDELAY - Wait time for a container to shut down.
#   Container shutdown can result in lengthy system
#   shutdown times.  Even 5 seconds per container can be
#   too long.
SHUTDOWNDELAY=5

# OPTIONS can be used for anything else.
#   If you want to boot everything then
#   options can be "-a" or "-a -A".
OPTIONS=

# STOPOPTS are stop options.  The can be used for anything else to stop.
#   If you want to kill containers fast, use -k
STOPOPTS="-a -A -s"

USE_LXC_BRIDGE="false"  # overridden in lxc-net

[ ! -f /etc/sysconfig/lxc-net ] || . /etc/sysconfig/lxc-net

或者/etc/sysconfig/lxc-net如果它存在(不在我的例子中)。就我而言,桥名称是lxcbr0并且它不会使用 lxc 桥接配置。

解决后,我们使用以下命令创建新的桥接口配置:

sudo sh -c '
cat > /etc/sysconfig/network-scripts/ifcfg-lxcbr0 <<EOF
DEVICE="lxcbr0"
BOOTPROTO="static"
IPADDR="192.168.1.250"
NETMASK="255.255.255.0"
ONBOOT="yes"
TYPE="Bridge"
NM_CONTROLLED="no"
EOF
'

我们从以下开始

须藤 ifup lxcbr0

您还必须重新启动 lxc 和 lxc-net

须藤系统ctl停止lxc

sudo systemctl 停止lxc-net

sudo systemctl 启动 lxc-net

须藤systemctl启动lxc

答案4

如果您docker安装了lxc来宾也可以使用docker0 bridge

/var/lib/lxc/container/config集合中

lxc.network.link = docker0
lxc.start.auto = 1

& 在文件中为访客提供静态 IP 地址里面容器:

/etc/sysconfig/network-scripts/ifcfg-eth0 

DEVICE=eth0
ONBOOT=yes
HOSTNAME=
NM_CONTROLLED=no
TYPE=Ethernet
MTU=
DHCP_HOSTNAME=centos6
BOOTPROTO="static"
IPADDR=172.17.xx.xx
NETMASK=255.255.255.0
GATEWAY=172.17.xx.1    # check ifconfig on the host for the docker0 ip

启用lxc服务,来宾将通过网络自动启动:

systemctl enable lxc.service

相关内容