My task is to use a virtual machine with OpenWRT (or OPNsense) as a virtual router, connecting it to the internet from the provider and various local networks, which should form a single unified network. The host machine is running Windows Server 2016 Nano Server with the Hyper-V role and has 3 physical network adapters.
When attempting to configure the VM as a router, I encountered an issue. However, to eliminate the influence of drivers and incorrect settings of physical network adapters, let's consider a scenario with fully virtual adapters and a virtual switch.
Here's the step-by-step process:
- Create a virtual switch of the "Private Switch" type.
- Set up a second-generation Router VM (VM1) with three vNICs. Connect the first vNIC to the virtual switch.
- Create a second-generation Client VM (VM2) with one vNIC and connect it to the same virtual switch.
- Install OpenWRT or OPNsense on VM1. By default, they will define the first port as LAN, set up a DHCP server, and be ready to assign IP addresses.
- Install any OS on VM2 and obtain an IP address. At this point, everything seems to be going according to plan. The machines see each other, and the client VM received an IP address.
Now, let's simulate the connection of a second network, using existing connections:
- On VM1, create a bridge (which is by default created in OpenWRT, for OPNsense use https://docs.opnsense.org/manual/how-tos/lan_bridge.html) and connect vNIC1 and vNIC3 to this bridge (vNIC2 is assumed to be WAN and is not connected yet).
- Our expectation is that both networks connected to vNIC1 and vNIC3 will see the router, receive IP addresses through DHCP, and be able to communicate with each other.
For testing the functionality of the second network:
- Disconnect vNIC1 of VM1 from the virtual switch and connect vNIC3 to the virtual switch.
- We expect that our client VM2 should obtain an IP address from the router just as before. However, the client does not receive an IP address. It sends a request, the router receives it, attempts to assign an IP, but the issue is that VM2 is not receiving data through the network connection (received = 0).
I've tested the exact same scenario on VMware Workstation Pro, and it works as expected without any issues. Not to advertise, just to clarify that it should work. I'm sticking with Hyper-V, so I'm really looking for a way to fix this.