我正在尝试使用多虚拟机无聊的环境作为部署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接口均已设置为混杂模式。