If you don't want to use Hyper V's default private network switch that gets a random IP on every reboot here is the solution.

  1. Open up a power shel as administrator
  2. Create a new network interface:
    New-VMSwitch -SwitchName "NATNetworkSwitch" -SwitchType Internal
  3. Assign an IP to it:
    New-NetIPAddress -IPAddress -PrefixLength 24 -InterfaceAlias "vEthernet (NATNetworkSwitch)"
  4. Enable NAT:
    New-NetNAT -Name "NATNetwork" -InternalIPInterfaceAddressPrefix


Credit: https://mytechiethoughts.com/windows/easy-internet-access-for-hyper-v-guests-using-nat/