Skip to content

Multiple WSL2 VMs maintain the same IP address #36

@mbrownnycnyc

Description

@mbrownnycnyc

I've created multiple WSL2 VMs based on the latest ubuntu distro appx.

Whenever I change the IP address of one, it changes the IP address of them all.

PS C:\ [06:10:54]> wsl -l -v
  NAME                   STATE           VERSION
* kali-linux             Stopped         2
  ubuntu_control         Stopped         2
  ubuntu_workernode1     Stopped         2
  ubuntu_baseline        Stopped         2
  docker-desktop         Running         2
  docker-desktop-data    Stopped         2
  ubuntu_workernode2     Stopped         2
  ubuntu_workernode3     Stopped         2

PS C:\ [06:13:46]> Install-WslIpHandler -WslInstanceName ubuntu_control -GatewayIpAddress 192.168.143.1 -WslInstanceIpAddress 192.168.143.111
PowerShell installing Wsl-IpHandler to ubuntu_control...
Test of Wsl-IpHandler Installation on ubuntu_control Succeeded!
PowerShell successfully installed Wsl-IpHandler to ubuntu_control.

PS C:\ [06:14:01]> wsl -d ubuntu_control hostname -I
192.168.143.111

PS C:\ [06:14:25]> Install-WslIpHandler -WslInstanceName ubuntu_workernode1 -GatewayIpAddress 192.168.143.1 -WslInstanceIpAddress 192.168.143.112
PowerShell installing Wsl-IpHandler to ubuntu_workernode1...
Test of Wsl-IpHandler Installation on ubuntu_workernode1 Succeeded!
PowerShell successfully installed Wsl-IpHandler to ubuntu_workernode1.

PS C:\ [06:15:08]> wsl -d ubuntu_workernode1 hostname -I
192.168.143.112

PS C:\ [06:14:01]> wsl -d ubuntu_control hostname -I
192.168.143.112

PS C:\ [06:16:05]> wsl -d ubuntu_workernode2 hostname -I

Settings 'appendWindowsPath' in [interop] section is disabled in /etc/wsl.conf!
This setting must be enabled for Wsl-IpHandler to work. Please confirm if you want to continue:
[F] Fix  [N] No  [Y] Yes  [?] Help (default is "F"): f
192.168.143.112

PS C:\ [06:16:27]> wsl -d ubuntu_workernode3 hostname -I

Settings 'appendWindowsPath' in [interop] section is disabled in /etc/wsl.conf!
This setting must be enabled for Wsl-IpHandler to work. Please confirm if you want to continue:
[F] Fix  [N] No  [Y] Yes  [?] Help (default is "F"): f
192.168.143.112

PS C:\ [06:16:31]> wsl -d kali-linux hostname -I
cat: /etc/wsl.conf: No such file or directory
192.168.143.112

If I start an interactive shell with -d, the IP of all of the WSL2 VMs changes to the IP address of the last VM I've started a shell in.

It appears that this is discussed in detail with an example here. Note that as in, this only allows traffic to be routed across the bridge, which exists within the subsystem, therefore I don't believe it's accessible via a vSwitch in ICS.

Alone, this is still valuable. Can this be implemented?

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