Hello,
In order to fully understand nested virtualization we need to take two steps back and start from the beginning of Networking. Real world physical networks use Network switches . A switch operates by learning the MAC address of the devices it is connected to creating a table mapping between MAC address and physical port. This way, when it is time to forward a packet to a specific destination address, the switch will only forward it to the relevant port.
If the switch doesn't know where to forward a specific packet (because, for example, it contains a new destination address) it will "flood" all ports - except the source port.
This behavior applies when forwarding traffic within the same IP subnet. Devices leverage the ARP protocol in order to resolve IP addresses to MAC addresses. So a device will populate the destination MAC address with the one he learnt from the destination, and the switch will do the rest. Instead when a packet is destined to a IP address that does NOT belong to the same subnet, it will be forwarded to a router (either a specific one if a route is defined, or to the default gateway). When the router forwards a packet to a different network, it changes the source MAC address to its own, and the destination MAC address to the next hop. MAC addresses are not preserved in IP datagrams when they travel accross different networks. (this property will play a role in Nested Virtualizaton later)
When you use virtual machines with Hyper-V, the virtualization software (Hypervisor) needs to find a way to map the physical MAC address of the hyper-V host to the virtual MAC addresses of the virtual machines it manages. This translation is done by Hyper-V's virtual switch. The virtual switch then becomes the software representation of the physical networking switches, but behaves in a slightly different way. By default:
- The virtual network adapter MAC address cannot be moved or associated with another virtual switch port.
- The virtual switch port does not forward unicast flooded packets (packets that are forwarded to all switch ports if the destination MAC address is not found in the switch forwarding table) to the virtual network adapter. This is done in order to prevent unwanted traffic to leak to a certain virtual machine. This configuration has an important consequence for the nested virtualization.
When it comes to Nested Virtualization, you will build a virtual machine inside another one. In order to do so, you need to install Hyper-V on a Virtual Machine (called the Virtual Host) as well as having Hyper-V running on the physical host. This implies the presence of two Virtual switches in a row on the path from the external network to the nested virtual machine.
Now imagine that a device on the external network needs to send traffic to the Nested VM 1 in the picture. But Nested VM 1 has MAC address of :1A and this MAC address is not present in the forwarding table of the physical hosts' Virtual switch, which only knows about MAC addresses :1B :2B and :3A
Since by default such Virtual Switch can not find information about :1A it is supposed to flood unicast packets searching for :1A but this is blocked by design as we discussed above. So natively, this configuration won't work.
The way to make Nested Virtualization work using Hyper-V on premises is enabling MAC spoofing on the physical hosts' Virtual switch. By enabling MAC spoofing:
- The virtual switch port that connects the virtual network adapter can send and receive packets that contain any MAC address.
- The virtual switch port dynamically learns of new MAC addresses and the virtual switch can add them in its forwarding table.
- The virtual switch port will receive and forward unicast flooded packets to the virtual network adapter.
Best Regards
Zunhui