Skip to content

Cannot create Hyper-V virtual switch #8

@truckee

Description

@truckee

Expected behavior

Edit: I highly suspect that I'm scrambling terms and that the observable IP addresses of the default switch is unrelated to the IP address of the VM. But, still, Objective: Create a PuTTY connection to Hyper-V VM from Windows 10. It does not appear to be possible to create an unchangeable IP address for the VM.

Running the command

G:\workspace\wsl-fix> .\Install-DeterministicNetwork.ps1 -NetworkType Hyper-V `
>>         -GatewayAddress 192.168.10.1 `
>>         -NetworkAddress 192.168.10.0/24

would create a virtual switch with those properties.

Observed behavior
The command returns this response:

Host: [2021-11-26 : 06:57:43] : Starting installation of the Hyper-V Network Fix.
Host: [2021-11-26 : 06:57:43] : These messages will be logged to: G:\workspace\wsl-fix\Install-Deterministric-Hyper-V-Network.log
Host: [2021-11-26 : 06:57:43] : Generated Tasks will be run as GWB-10\George with SID: S-1-5-21-1621994925-3669255815-1728145884-1004
Host: [2021-11-26 : 06:57:43] : Scripts will be copied to directory: C:\Users\George\Hyper-V-Network-Fix
Host: [2021-11-26 : 06:57:43] : Copying scripts into place...
Host: [2021-11-26 : 06:57:43] : Staging task definitions to: C:\Users\George\AppData\Local\Temp\Hyper-V-tasks
Host: [2021-11-26 : 06:57:43] : Updating the staged task definitions:
Host: [2021-11-26 : 06:57:43] : Registering the startup/login task...
Host: [2021-11-26 : 06:57:44] : All done. Hyper-V Network Fix Startup Script has been installed.

No new virtual switch is created as viewed in Hyper-V manager or control panel network connections.

Following instead the notion that one needs to run the Hyper-V Network Fix Startup Script as suggested above, I observed the following:

PS C:\Users\George\Hyper-V-Network-Fix> .\Register-DeterministicNetwork

cmdlet Register-DeterministicNetwork.ps1 at command pipeline position 1
Supply values for the following parameters:
GatewayAddress: 172.26.0.1
NetworkAddress: 172.26.0.2/16
Host: [2021-11-26 : 06:41:31] : Network Configuration to Create:
Host: [2021-11-26 : 06:41:31] : {
    "Name" : "WSL",
    "Flags": 9,
    "Type": "ICS",
    "Subnets" : [
        {
            "ID" : "21894f4e-9f9c-41b5-b8ef-87948943c15e",
            "AddressPrefix" : "172.26.0.2/16",
            "IpSubnets" : [
                {
                    "ID" : "28d2abf3-7d0a-45e8-9954-62e2d24269a6",
                    "Flags": 3,
                    "IpAddressPrefix": "172.26.0.2/16"
                }
            ]
        }
    ],
    "IsolateSwitch": true,
    "DNSServerList" : "172.26.0.1"
}
Exception: C:\Users\George\Hyper-V-Network-Fix\HCN.ps1:273
Line |
 273 |              throw $errString
     |              ~~~~~~~~~~~~~~~~
     | HcnCreateNetwork -- HRESULT: 2147943568. Result: {"Success":false,"Error":"Element not found.
     | ","ErrorCode":2147943568}

There is no indication of what element is required.

So I guess I'm missing something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions