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

Static IP for 2 different wsl2 distros on same pc #3

Open
Camrule opened this issue Jan 6, 2023 · 4 comments
Open

Static IP for 2 different wsl2 distros on same pc #3

Camrule opened this issue Jan 6, 2023 · 4 comments

Comments

@Camrule
Copy link

Camrule commented Jan 6, 2023

Hey there,

Thanks so much for your guide! Has helped me immensely. I'm wondering if there would be an easy solution to set static IP for 2x wsl2 Linux on the same pc?

Cheers!

@luxzg
Copy link
Owner

luxzg commented Jan 6, 2023

I haven't tested with them running at the same time, it should work, just set one IP in one OS, other IP in other OS. You should NOT use static MAC in that case (I think) as it would likely confuse networking stacks. So let the WSL handle mac, and you handle the IPs.

@Camrule
Copy link
Author

Camrule commented Jan 10, 2023

Hey thanks for that. But that is my issue. I do not know how to set it. Do you have any idea how to do that?

@luxzg
Copy link
Owner

luxzg commented Jan 10, 2023

Sure, here's the general idea.
Follow my guide, just make sure NOT TO set wslconfig option macAddress=....
Go through the procedure for VM distro no 1, and let's say you give it static IP 192.168.0.101.
Then go through same procedure with VM No 2 and when setting static IP just give it next in line for example 192.168.0.102
Start both VMs and try pinging one from the other and if that works everything should work.

Note that "global" settings (eg. Hyper-V vSwitch, and options inside wslconfig) apply to all VMs / distros / instances. So when setting 2nd one, you don't actually need to set anything, because you've already done it when setting 1st one. Both will use same vSwitch and same wslconfig settings.

Hope that helped!

P.S. IP s above are just an example, make sure to adjust them to your real network

@micheldiemer
Copy link

Here a detailed working procedure on how to use WSLAttachSwitch

Script : microsoft/WSL#4799 (comment)

Text : microsoft/WSL#4799 (comment)

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

3 participants