Having Windows 10 Pro gives access to Hyper-V as a virtualisation platform. Needing some VMs locally on my laptop I added the Hyper-V package to Windows and set about getting things configured. However, when setting up the networking, specifically, an external virtual switch I was getting the following errors:
Error applying Virtual Switch Properties changes
Adding ports to the switch failed
The operation failed because the object was not found.
Further attempts to create a External Virtual Switch yield the error 0x800700B7
There is much speculation online going back to 2016 around errors with Hyper-V virtual switches as to what the problem is. The usual answers of driver updates, software version updates help some but for those of us trying this from a wireless network adapter there seems no solid fix.
The workaround
Create an Internal Virtual Switch, then share the Wireless adapters Internet connection with it.
1. Create an Internal Virtual Switch in the normal way via the Virtual Switch Manager.
2. Go to the Network and Sharing Centre, view the status of the Internal Switch, then its Properties, then the Internet Protocol Version 4 (TCP/IPv4) properties. Note down the IP address (I changed mine from the default)
3. From the Network Connections page (adapter settings) open the properties of the Wireless adapter. There should be a Sharing tab (if you view the properties from the Network and Sharing Centre the sharing tab is not shown!)
Check both boxes and select the appropriate Hyper-V Virtual Switch from the drop down
4. Assign the Internal Virtual Switch in the networking portion of the guest VM in Hyper-V
5. Inside your guest VM set a static IP as per your OS within the range of the Virtual Switch IP, making the default gateway that of the Virtual Switch. This will then piggyback on the shared Internet connection of the Wireless adapter.
Notes
If running Windows as a guest VM then you may get away with using APIPA (Automatic Private IP Addressing) having the guest use a 169.254… address which may allow the shared Internet connection to function. As I am not using a windows guest I do not know if this is guaranteed.
Alternatively, you can run a DHCP service on your host laptop, perhaps even a virtualised instance of OPNsense
CISCO AnyConnect VPN error
It seems that if you try and use the CISCO AnyConnect VPN software to initiate a remote tunnel after enabling the sharing of Internet access via your wireless card it will fail.
If you try and re-install AnyConnect with ICS (Internet Connection Sharing) enabled you get the following error:
the vpn client agent was unable to create the interprocess communication depot
The only option is to undo the change and disable the sharing of your wireless connection with the Internal Virtual Switch. You can only have one or the other, so remember to re-enable sharing when you want to access the Internet via your VM. Sadly I have not found a way to have the VM access a resource over an AnyConnect VPN!
Windows 10 IPSec IKEv2 error
If you have a IPSec VPN through Windows 10 you may well get the following error (again, related to the enabling of ICS)
Error 87: the parameter is incorrect
To resolve this I had to reset the network stack in Windows and delete / install the WAN Miniport network adapers from Device Manager
Reset Windows 10 network stack
From an elevated command prompt:
netsh int ip reset
netsh int ipv6 reset
netsh winsock reset
Restart as requested to complete the reset.
Remove and reinstall VPN WAN Miniport network adapers
From device manager uninstall all the WAN Miniport network adapters highlighted below
Automatically reinstall the network components via Action > Scan for hardware changes.
The VPN should now work again