By default, HyperVs will use the internal “Default Switch” for network connectivity and provide DHCP for the VM. It is possible, instead, to create and external switch that will then pull from your network to get DHCP.
Be warned: if you’re doing this at home it means there’s a new machine running on the network – you need to ensure that it is locked down. Also, if you do this at the office, you may be running afoul of your network security rules. Be careful.
The process of installing a new External Switch
Process is simple. Note that this could disconnect you from the network as it is now going to bind to your physical network adapter. Again, if you’re in a professional environment this might not be something you want to ask forgiveness for later.
Open Hyper-V Manager > right click > Virtual Switch Manger
Under “What type of virtual switch do you want to create?”, click External (should be default), then Create Virtual Switch.
Change the name of the switch
In the dropdown, select your physical network adapter and hit Apply or Ok.
Once the process completes, shut down your VM, then assign the new adapter and restart it.
Setting a static IP address in the VM in Centos 7
In my case (at home), I wanted to set a static IP so I could map a local hostname to it for development.
Since DHCP is now being pulled from my router, I went it and set the DHCP range from 192.168.1.2 to 192.168.1.254 to 192.168.1.2 to 192.168.1.199. So, 192.168.1.200 would be the first static IP to use.
CentOS 7 has nmtui, a simple GUI (installed by default) for editing connections (much easier IMHO that going through files). I had already disabled IPV6, but do that while you’re there if you have not. Then modify eth0 (typical card in CentOS) to static IP. Restart network.
Try pinging your new VM from your Windows machine.