Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple WSL2 VMs maintain the same IP address #36

Open
mbrownnycnyc opened this issue Feb 14, 2023 · 1 comment
Open

Multiple WSL2 VMs maintain the same IP address #36

mbrownnycnyc opened this issue Feb 14, 2023 · 1 comment

Comments

@mbrownnycnyc
Copy link

mbrownnycnyc commented Feb 14, 2023

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?

@wikiped
Copy link
Owner

wikiped commented Feb 14, 2023

On the page you linked there is an answer that outlines the reasons why this odd behavior you noticed is happening.

This is a WSL quirk, that this module cannot solve on its own.

And my understanding is that in essence there is choice to make:

  1. Work with each WSL instance separately (i.e. all other instances must be stopped) and have full network connectivity;
  2. Make multiple WSL instances working together "under a bridge", but sacrifice external connectivity.

The module as it is now is opting for option 1.

Whether option 2 can be a feature the module can offer remains to be seen as it seems like a drastic change of some of the internals. At the very least what you can do is replace content of /usr/local/bin/wsl-iphandler.sh script at all WSL instances with the one in the link you posted and it will provide you the functionality you are looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants