TIL About Hyper-V

Hyper-V VMs and Switches

  ·   2 min read

Hyper-V General #

Creating a Virtual Machine #

  • Run Hyper-V manager
  • New > Virtual Machine
  • Change name
  • Generation 2 for 64 bit
  • Memory as needed and dynamic
  • If switch already exists, select it
  • Create virtual hard disk (defaults)
  • Install from iso image (windows evaluation center)

Afterwards start the VM and press any key when prompted. You can then install Windows as needed.

Creating a Virtual Switch #

  • Run Hyper-V manager
  • Virtual Switch manager
  • New virtual network switch
  • Select type
  • Create virtual switch

Afterwards you need to connect the VMs to the created switch.

Attach VM to Switch #

  • Select VM > right click > Settings
  • Network Adapter
  • Select virtual switch

If the VM is of Generation 2, it can be done while it’s running.

One thing to keep in mind: Without a DHCP server, the VMs are not going to get an IP address automatically.

So we need to set that manually.

Manually configure IPs #

  • Open Network and Internet Settings
  • Change adapter options
  • Select right adapter > Properties
  • TCP/IPv4 > Properties
  • Use the following address
    • E.g: 10.10.10.1 with 255.255.255.0 for a /24 network

You also need to make sure the Windows firewall allows the ping:

  • Windows Defender Firewall
  • Advanced settings
  • Inbound rules
  • File and Printer Sharing (Echo Request - ICMPv4-In)

Switch Types #

Private Switch #

  • Virtual machines are connected
  • No connection to the host system or the LAN of the host machine
  • No internet connection

Allows us to test things in an isolated lab environment. We cannot cause any damage to our real environment.

Internal Switch #

  • Creates virtual adapter on the host machine
  • Virtual adapter will become part of the virtual network
  • Host machine can then partake in the virtual network
  • Cannot talk to other LAN or internet

Default Switch #

  • Exists by default (so does not need to be created)
  • NAT based
  • Allocated IP addresses via DHCP
  • Connects virtual machines to the LAN of the host as well as the internet
  • Default switch adapter on host acts as default gateway for Vms

External Switch #

  • VMs will use the physical network interface of the host machine
  • Creates virtual network adapter on host
    • Can choose if host is part of the network
  • Connects to host LAN
  • Should get IP from LAN