TL;DR - the short question:
Can a host be configured to be able connect to a VM being hosted by the host itself, when the VM is set to use an
External Virtual Switch with the
Allow management operating system to share this network adapter enabled?
If so, how?
I'm trying to run a VM on a Windows 10 (1903) PC using Hyper-V (i.e. the host itself).
I have three overarching goals:
1.) Connect to the VM from the host itself - e.g. http, ssh etc.
2.) Connect to the VM from other PC's on the LAN - e.g. http, ssh etc.
3.) Connect to the LAN and internet from the VM.
The VM is configured in Hyper-V to use an
External Virtual Switch. The
Allow management operating system to share this network adapter option is enabled. If I disable it, the host loses it's network connectivity.
I have only one NIC on the PC.
So far 2.) and 3.) works fine:
The VM gets it's own ip address (from the DHCP server on the LAN or statically).
I can ping the VM from another PC on the network.
I can also ssh into the VM from another PC on the network etc.
However, 1.) does not work. I am unable to ping, ssh or otherwise access the VM from the host itself. I can only do this from remote PC's on the LAN.
How do I fix this? Can it be done?
I've been pulling my hair, reading posts and trying differnt solutions for the past days, but so far no luck.
Note: Some seem to point in the direction of using
Internal Virtual Switch and maybe adding a NAT. I've tried that too, however this just leads to the VM being unable to connect to network. Nor is the host or remote PC's able to connect to the VM. So all in all, this approach currently misses on all 3 goals. Not sure why, as the NAT configuration seems rather straight forward, but maybe related to the OS I'm using in the VM (ESXi 6.0).
I haven't solved the core issue, but I've found a work-around:
I added a #2 NIC to the host and moved the
External Virtual Switch to this 2nd NIC. I also disabled
Allow management operating system to share this network adapter on the
External Virtual Switch.
With this work-around I can now access the VM from both the host and from other devices on the LAN.
I made no other changes.