Attach external NIC to a NAT-Network if on Wi-Fi
On computers with wi-fi adapters, promiscuous mode on the VirtualBox (or maybe other hypervisors as well) NICs does not work, which means the default way of connecting the Neutron external interface to a bridged adapter, will not allow communication to and from the Nova VMs over floating IPs with any computer on the external network (except the host computer) or with the wi-fi router. This means no ability to connect to the Nova VMs and no internet access inside the Nova VMs. According to VirtualBox documentation (excerpt): "Bridging to a wireless interface is done differently from bridging to a wired interface, because most wireless adapters do not support promiscuous mode. All traffic has to use the MAC address of the host’s wireless adapter, and therefore VirtualBox needs to replace the source MAC address in the Ethernet header of an outgoing packet to make sure the reply will be sent to the host interface. When VirtualBox sees an incoming packet with a destination IP address that belongs to one of the virtual machine adapters it replaces the destination MAC address in the Ethernet header with the VM adapter’s MAC address and passes it on. VirtualBox examines ARP and DHCP packets in order to learn the IP addresses of virtual machines." To fix this issue, a new flag has been introduced: WIFI. If true, the default Vagrant public network is not created anymore. Instead, the 3rd NIC will be connected to a NAT-Network named OSNetwork. The NAT-Network has a virtual gateway, which will be used to communicate with the external physical wi-fi router. Since Vagrant does not have a high-level mechanism to attach an adapter to a NAT-Network, the code uses the low-level Vagrant construct vm.customize which makes it provider specific. Promiscuous mode is now activated by default on the 3rd NIC. The WIFI flag is false by default. This commit only addresses VirtualBox, and it is currently unknown if the problem described and fixed in this commit is present in other hypervisors. DocImpact Closes-Bug: #1558766 Change-Id: I0b4dbbc562d87191b2179f47b634cdd6f6361a5e Signed-off-by: Andrei-Lucian Șerb <lucian.serb@icloud.com>
This commit is contained in:
parent
f096cdcb40
commit
3b12b7b951
45
dev/vagrant/Vagrantfile
vendored
45
dev/vagrant/Vagrantfile
vendored
@ -56,6 +56,12 @@ PROVIDER_DEFAULTS ||= {
|
||||
}
|
||||
}
|
||||
|
||||
# Whether the host network adapter is Wi-Fi.
|
||||
# On VirtualBox, the user must first manually create a NAT-Network
|
||||
# named "OSNetwork". The default network CIDR must be changed.
|
||||
# The Neutron external interface will be connected to this Network.
|
||||
WIFI = false unless self.class.const_defined?(:WIFI)
|
||||
|
||||
# Whether to do Multi-node or All-in-One deployment
|
||||
MULTINODE = false unless self.class.const_defined?(:MULTINODE)
|
||||
|
||||
@ -112,6 +118,38 @@ rescue
|
||||
"Missing configuration for NODE_SETTINGS[#{node}][#{setting}]"
|
||||
end
|
||||
|
||||
def configure_wifi_vbox_networking(vm)
|
||||
# Even if adapters 1 & 2 don't need to be modified, if the order is to be
|
||||
# maintained, some modification has to be done to them. This will maintain
|
||||
# the association inside the guest OS: NIC1 -> eth0, NIC2 -> eth1, NIC3 ->
|
||||
# eht2. The modifications for adapters 1 & 2 only change optional properties.
|
||||
# Adapter 3 is enabled and connected to the NAT-Network named "OSNetwork",
|
||||
# while also changing its optional properties. Since adapter 3 is used by
|
||||
# Neutron for the external network, promiscuous mode is set to "allow-all".
|
||||
# Also, use virtio as the adapter type, for better performance.
|
||||
vm.customize ["modifyvm", :id, "--nictype1", "virtio"]
|
||||
vm.customize ["modifyvm", :id, "--cableconnected1", "on"]
|
||||
vm.customize ["modifyvm", :id, "--nicpromisc2", "deny"]
|
||||
vm.customize ["modifyvm", :id, "--nictype2", "virtio"]
|
||||
vm.customize ["modifyvm", :id, "--cableconnected2", "on"]
|
||||
vm.customize ["modifyvm", :id, "--nic3", "natnetwork"]
|
||||
vm.customize ["modifyvm", :id, "--nat-network3", "OSNetwork"]
|
||||
vm.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
|
||||
vm.customize ["modifyvm", :id, "--nictype3", "virtio"]
|
||||
vm.customize ["modifyvm", :id, "--cableconnected3", "on"]
|
||||
end
|
||||
|
||||
def configure_wifi_if_enabled(vm)
|
||||
if WIFI
|
||||
case PROVIDER
|
||||
when "virtualbox"
|
||||
configure_wifi_vbox_networking(vm)
|
||||
# TODO(lucian-serb): Configure networking on Wi-Fi for other hypervisors.
|
||||
# when "libvirt"
|
||||
# configure_wifi_libvirt_networking(vm)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Vagrant.configure(2) do |config|
|
||||
config.vm.box = get_default(:base_image)
|
||||
@ -120,7 +158,12 @@ Vagrant.configure(2) do |config|
|
||||
# nodes attached. Plus, each node receives a 3rd adapter connected to the
|
||||
# outside public network.
|
||||
config.vm.network "private_network", type: "dhcp"
|
||||
# On VirtualBox hosts with Wi-Fi, do not create a public bridged interface.
|
||||
# A NAT-Network will be used instead.
|
||||
# TODO(lucian-serb): Do the same for other hypervisors as well?
|
||||
unless PROVIDER == "virtualbox" && WIFI
|
||||
config.vm.network "public_network", dev: get_default(:bridge_interface), mode: 'bridge', type: 'bridge'
|
||||
end
|
||||
|
||||
my_privatekey = File.read(File.join(vagrant_dir, "vagrantkey"))
|
||||
my_publickey = File.read(File.join(vagrant_dir, "vagrantkey.pub"))
|
||||
@ -170,6 +213,7 @@ Vagrant.configure(2) do |config|
|
||||
if PROVIDER == "libvirt"
|
||||
vm.graphics_ip = GRAPHICSIP
|
||||
end
|
||||
configure_wifi_if_enabled(vm)
|
||||
end
|
||||
admin.hostmanager.aliases = "operator"
|
||||
end
|
||||
@ -190,6 +234,7 @@ Vagrant.configure(2) do |config|
|
||||
if PROVIDER == "libvirt"
|
||||
vm.graphics_ip = GRAPHICSIP
|
||||
end
|
||||
configure_wifi_if_enabled(vm)
|
||||
end
|
||||
node.hostmanager.aliases = hostname
|
||||
end
|
||||
|
@ -49,6 +49,12 @@
|
||||
# }
|
||||
# }
|
||||
|
||||
# Whether the host network adapter is Wi-Fi.
|
||||
# On VirtualBox, the user must first manually create a NAT-Network
|
||||
# named OSNetwork. The default network CIDR must be changed.
|
||||
# The Neutron external interface will be connected to this Network.
|
||||
# WIFI = false
|
||||
|
||||
# Whether to do Multi-node or All-in-One deployment
|
||||
# MULTINODE = false
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user