Saturday 3 March 2018

Hyper-V networking

In Hyper-V I had a Virtual Network Switch, 'NAT', which I could not delete.
I found that this was associated with docker.

running docker network list indicated the network:

a1b23ca940cb        Default Switch                 ics                 local
dd38da06ad19        Minikube                       transparent         local
e1f9b2de34f2        Wired Hyper-V Virtual Switch   transparent         local
b927d4e2fab9        nat                            nat                 local
20a4b1e6aec4        none                           null                local

ics is Internet Connection Sharing.

the nat switch is created by Docker For Windows and is used for Windows containers.
Conversely, if you use Linux mode then Docker for Windows creates the DockerNAT switch.

If you create a Hyper-V external switch then a bridge is also required. It connects the
Wireless Network Connection adapter to the MAC Bridge Filter, the LLDP protocol driver and the Hyper-V Extensible Virtual Switch.

This article explains why:

This article explains a lot about the Windows networking

Moby Linux VMs use DockerNAT switch with Docker for Windows (a product of Docker CE) instead of HNS internal vSwitch
Docker for Windows (the Windows driver for the Docker CE engine) on Windows 10 will use an Internal vSwitch named 'DockerNAT' to connect Moby Linux VMs to the container host. Developers using Moby Linux VMs on Windows should be aware that their hosts are using the DockerNAT vSwitch rather than the vSwitch that is created by the HNS service (which is the default switch used for Windows containers).

To get the docker container to have access to the network (as if it were a peer to the host)

docker network ls

NETWORK ID          NAME                              DRIVER              SCOPE
acd360485ea3        Wired Hyper-V Virtual Switch      transparent         local
cf9c25350a73        Wireless Hyper-V Virtual Switch   transparent         local
bf621e7722a1        nat                               nat                 local
1655e1f6e86f        none                              null                local

docker run --network "Wired Hyper-V Virtual Switch" -ti microsoft/nanoserver ping

To set up a good development machine you would expect:

Network Bridge - using the Wireless Network Connection adapter and connecting the Hyper-V Extensible Virtual Switch, Microsoft LLDP Protocol Driver and Microsoft MAC Bridge.


Do not configure the Local Area Network Connection for TCP/IP settings. This should be done at the Hyper-V virtual switch level.

Test your main wireless and wired host networking.
Test a normal Hyper-V VM's access to the internet, via wireless and wired independently.
Test a Docker containers access to the internet.
Test MiniKubes ability to start up and get an IP address.

No comments:

Post a Comment