Problems when working hyper-v on a wi-fi network
Hello dear readers, please do not throw tomatoes at me because of such a strange use of virtualization, I have a fairly good wireless network at home with a ping of less than 1ms and a speed of about 90Mbps, there is only one wall between the router and the computer and it has no metal fittings, but pull a wire to a computer is problematic. I needed to keep the Linux server in constant access to the external network and so that it worked in the background and started up when the computer was turned on, as Windows 10 pro has hyper-v, why not use it. But I was very upset when virtual machines began to periodically lose contact with the outside world, ping losses reached 20-40%.
The virtual switch was configured on an external network, i.e. Forwarded the bridge to the local wireless network. After working one day, I found that the site is often inaccessible from the outside, and after 30 seconds it works again, and then it repeated. At first, I could not understand what was happening for a long time, I got out my laptop, started pinging the virtual machine, the pings go and the site is already open at that moment, then I launched the pings from the virtual console, found the breaks, at the same time I started the ping from the host system, everything is perfect, 0 % loss.
For about three days I crawled through various forums in search of an answer, but everywhere people referred to the fact that the host system was taking resources from virtual machines, that Windows 10 was such a curve, and we had to install a server system for such purposes, but that was not the reason.
It turns out that when creating the bridge, virtual network interfaces with different mac addresses go out through my network card, as a result one network card goes on the network with different macs, if it works fine on a wired network, then in a wireless network this behavior causes inadequate network operation, some wi-fi cards will not have such problems, but most have problems.
To solve the problem with the stability of the connection of virtual machines, you need to use NAT and forward ports. There are a lot of instructions on the network how to do this, but with a simple opening of access on an external network card, this will not work.

And now, in order, first we need to create a virtual switch with the type of “internal network”, a virtual interface will appear in the network connections, it will be the link with the virtual machines. For virtual machines, we set IP addresses on a subnet that is different from our local network. If we have a 192.168.0.0/24 subnet in the local network, then for example, we will create 192.168.137.0/24 in the virtual network, set 192.168.137.100 to our virtual machine, and 192.168.137.1 to the virtual interface and this will be the gateway for our machines.
And now about NAT, the usual way with sharing the interface will work until the first reboot of the host machine, most likely the virtual interface appears on the system later than the real network card with its shared access and NAT just crashes, and we need everything to work right away when you turn on the computer. This instruction comes to the rescue , open the PowerShell console as an administrator and enter there:
Once again we check that ip is not lost on the virtual network card on the host system, now about port forwarding in the same console
As a result, when accessing our computer on port 8080, the request will be forwarded to our virtual machine from ip 192.168.137.100 to port 80.
Then you can forward the 80th port from the router to our 8080 machine and the virtual web server will be accessible from the outside, similarly it can be done with ftp, ssh and other necessary services.
I hope that someone else, faced with such a problem, will not reinstall the drivers, rearrange the different checkmarks in the hyper-v settings and update the kernel in Linux, but will immediately do NAT. Such a setup is not suitable for battle servers, but it will do for any home temporary servers.
The virtual switch was configured on an external network, i.e. Forwarded the bridge to the local wireless network. After working one day, I found that the site is often inaccessible from the outside, and after 30 seconds it works again, and then it repeated. At first, I could not understand what was happening for a long time, I got out my laptop, started pinging the virtual machine, the pings go and the site is already open at that moment, then I launched the pings from the virtual console, found the breaks, at the same time I started the ping from the host system, everything is perfect, 0 % loss.
For about three days I crawled through various forums in search of an answer, but everywhere people referred to the fact that the host system was taking resources from virtual machines, that Windows 10 was such a curve, and we had to install a server system for such purposes, but that was not the reason.
It turns out that when creating the bridge, virtual network interfaces with different mac addresses go out through my network card, as a result one network card goes on the network with different macs, if it works fine on a wired network, then in a wireless network this behavior causes inadequate network operation, some wi-fi cards will not have such problems, but most have problems.
To solve the problem with the stability of the connection of virtual machines, you need to use NAT and forward ports. There are a lot of instructions on the network how to do this, but with a simple opening of access on an external network card, this will not work.
And now, in order, first we need to create a virtual switch with the type of “internal network”, a virtual interface will appear in the network connections, it will be the link with the virtual machines. For virtual machines, we set IP addresses on a subnet that is different from our local network. If we have a 192.168.0.0/24 subnet in the local network, then for example, we will create 192.168.137.0/24 in the virtual network, set 192.168.137.100 to our virtual machine, and 192.168.137.1 to the virtual interface and this will be the gateway for our machines.
And now about NAT, the usual way with sharing the interface will work until the first reboot of the host machine, most likely the virtual interface appears on the system later than the real network card with its shared access and NAT just crashes, and we need everything to work right away when you turn on the computer. This instruction comes to the rescue , open the PowerShell console as an administrator and enter there:
New-NetNat -Name nat1 -InternalIPInterfaceAddressPrefix 192.168.137.0/24
Once again we check that ip is not lost on the virtual network card on the host system, now about port forwarding in the same console
netsh interface portproxy add v4tov4 listenport=8080 connectaddress=192.168.137.100 connectport=80 protocol=tcp
As a result, when accessing our computer on port 8080, the request will be forwarded to our virtual machine from ip 192.168.137.100 to port 80.
Then you can forward the 80th port from the router to our 8080 machine and the virtual web server will be accessible from the outside, similarly it can be done with ftp, ssh and other necessary services.
I hope that someone else, faced with such a problem, will not reinstall the drivers, rearrange the different checkmarks in the hyper-v settings and update the kernel in Linux, but will immediately do NAT. Such a setup is not suitable for battle servers, but it will do for any home temporary servers.