流浪者(Virtualbox)仅主机多节点联网问题


9

我正在尝试使用多虚拟机无聊的环境作为部署OpenStack的测试平台,并且在尝试从一个虚拟机与虚拟机内部的虚拟机进行通信时遇到了网络问题。

我有两个Vagrant节点,一个云控制器节点和一个计算节点。我正在使用仅主机网络。我的Vagrantfile看起来像这样:

Vagrant::Config.run do |config|

  config.vm.box = "precise64"

  config.vm.define :controller do |controller_config|
    controller_config.vm.network :hostonly, "192.168.206.130" # eth1
    controller_config.vm.network :hostonly, "192.168.100.130" # eth2
    controller_config.vm.host_name = "controller"
  end

  config.vm.define :compute1 do |compute1_config|
    compute1_config.vm.network :hostonly, "192.168.206.131" # eth1
    compute1_config.vm.network :hostonly, "192.168.100.131" # eth2
    compute1_config.vm.host_name = "compute1"
    compute1_config.vm.customize ["modifyvm", :id, "--memory", 1024]
  end
end

当我尝试启动(基于QEMU的)VM时,它会在compute1上成功启动,并且其虚拟NIC(vnet0)通过网桥br100连接:

root@compute1:~# brctl show 100
bridge name bridge id       STP enabled interfaces
br100       8000.08002798c6ef   no      eth2

                        vnet0

当QEMU VM向控制器上运行的DHCP服务器(dnsmasq)发出请求时,由于控制器上syslog上的输出,我可以看到请求到达了控制器:

Aug  6 02:34:56 precise64 dnsmasq-dhcp[12042]: DHCPDISCOVER(br100) fa:16:3e:07:98:11 
Aug  6 02:34:56 precise64 dnsmasq-dhcp[12042]: DHCPOFFER(br100) 192.168.100.2 fa:16:3e:07:98:11 

但是,DHCPOFFER永远不会使其返回到在compute1上运行的VM。如果我在运行Vagrant(Mac OS X)的主机上的vboxnet3接口上使用tcpdump查看请求,则可以同时看到请求和答复

$ sudo tcpdump -i vboxnet3  -n port 67 or port 68
tcpdump: WARNING: vboxnet3: That device doesn't support promiscuous mode
(BIOCPROMISC: Operation not supported on socket)
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on vboxnet3, link-type EN10MB (Ethernet), capture size 65535 bytes
22:51:20.694040 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from fa:16:3e:07:98:11, length 280
22:51:20.694057 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from fa:16:3e:07:98:11, length 280
22:51:20.696047 IP 192.168.100.1.67 > 192.168.100.2.68: BOOTP/DHCP, Reply, length 311
22:51:23.700845 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from fa:16:3e:07:98:11, length 280
22:51:23.700876 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from fa:16:3e:07:98:11, length 280
22:51:23.701591 IP 192.168.100.1.67 > 192.168.100.2.68: BOOTP/DHCP, Reply, length 311
22:51:26.705978 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from fa:16:3e:07:98:11, length 280
22:51:26.705995 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from fa:16:3e:07:98:11, length 280
22:51:26.706527 IP 192.168.100.1.67 > 192.168.100.2.68: BOOTP/DHCP, Reply, length 311

但是,如果我在eth2上通过tcpdump进行计算,则只会看到请求,而不会看到答复:

root@compute1:~# tcpdump -i eth2 -n port 67 or port 68
tcpdump: WARNING: eth2: no IPv4 address assigned
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth2, link-type EN10MB (Ethernet), capture size 65535 bytes
02:51:20.240672 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from fa:16:3e:07:98:11, length 280
02:51:23.249758 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from fa:16:3e:07:98:11, length 280
02:51:26.258281 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from fa:16:3e:07:98:11, length 280

在这一点上,我被困住了。我不确定为什么DHCP回复没有将其发送到计算节点。也许与VirtualBox虚拟交换机/路由器的配置有关?

请注意,两个节点上的eth2接口均已设置为混杂模式。

Answers:


11

问题在于,必须通过Vagrant将接口设置为混杂模式,仅在客户操作系统中进行操作是不够的。

例如,如果添加两个NIC,并且定义的最后一个NIC是将桥接到VM的NIC,则Vagrantfile应该包含以下内容:

compute1_config.vm.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]

3
您能否阐明“ nicpromisc3”指定了什么?
jayunit100

2
@ jayunit100它将第三个nic(与eth2对应)设置为“混杂模式”,这意味着即使数据包中目标主机的MAC地址与虚拟机的MAC地址不匹配,VirtualBox也会将数据包发送到VM。虚拟机。
Lorin Hochstein 2012年

1
那么--nicpromisc3是适配器3吗?因此--nicpromisc2是适配器2吗?
CMCDragonkai 2014年

@CMCDragonkai是的,我相信。
Lorin Hochstein 2014年

1
@Alfred请参阅此问题以了解如何解决该The following settings shouldn't exist: customize错误。
尼克·克雷格·伍德
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.