WSL 2 Networking
HTML-код
- Опубликовано: 6 июл 2024
- How do you access WSL 2 Virtual Machines remotely? I'll show you how WSL2 networking works and I'll also show you how to configure the proxy service on your Windows 10 computer to allow connections to your WSL virtual machines. I'll also explain the configuration of the Windows Firewall.
WSL 2 changes the way networking is configured compared to WSL 1. You need to enable proxy of traffic and you need to permit the traffic through the Windows firewall.
Menu:
Overview: 0:00
Network Setup: 0:48
Microsoft Documentation: 1:11
Virtual and Physical Networks: 2:12
Testing from Mac: 6:35
Port Proxy Command: 7:07
Testing from Mac Again: 8:24
Firewall Rules: 9:40
GitHub 4150 Script: 11:09
Pings fail: 13:05
WSL commands:
netsh interface portproxy add v4tov4 listenport=3390 listenaddress=0.0.0.0 connectport=3390 connectaddress=192.168.170.227
Firewall rules:
- Go to control panel and open advanced firewall rules
- allow port 3390 through firewall
github.com/microsoft/WSL/issu...
WSL 2 Playlist:
• WSL 2 (Windows Subsyst...
Good links:
WSL 2 Proxy Script: github.com/microsoft/WSL/issu...
Microsoft GUI announcement: devblogs.microsoft.com/comman...
Ubuntu WSL2 GUI Install: In Ubuntu WSL:
dev.to/darksmile92/linux-on-w...
WSL 2 install: docs.microsoft.com/en-us/wind...
Docker for WSL2: docs.docker.com/docker-for-wi...
What is WSL? docs.microsoft.com/en-us/wind...
WSL documentation: docs.microsoft.com/en-us/wind...
WSL 2 Announcement: devblogs.microsoft.com/comman...
WSL2
WSL 2
WSL 2 Networking
WSL 2 Proxy
WSL proxy
Docker
Ubuntu 20.04
Ubuntu GUI
WSL 2 Ubuntu GUI
WSL Ubuntu GUI
WSL 2
WSL 1
Ubuntu 18.04
windows subsystem for linux
wsl2 ubuntu gui
#wsl2 #ubuntu #windows Наука
Menu:
Overview: 0:00
Network Setup: 0:48
Microsoft Documentation: 1:11
Virtual and Physical Networks: 2:12
Testing from Mac: 6:35
Port Proxy Command: 7:07
Testing from Mac Again: 8:24
Firewall Rules: 9:40
GitHub 4150 Script: 11:09
Pings fail: 13:05
WSL commands:
netsh interface portproxy add v4tov4 listenport=3390 listenaddress=0.0.0.0 connectport=3390 connectaddress=192.168.170.227
Firewall rules:
- Go to control panel and open advanced firewall rules
- allow port 3390 through firewall
github.com/microsoft/WSL/issues/4150
Good links:
WSL 2 Proxy Script: github.com/microsoft/WSL/issues/4150
Microsoft GUI announcement: devblogs.microsoft.com/commandline/the-windows-subsystem-for-linux-build-2020-summary/
Ubuntu WSL2 GUI Install: In Ubuntu WSL:
dev.to/darksmile92/linux-on-windows-wsl-with-desktop-environment-via-rdp-522g
WSL 2 install: docs.microsoft.com/en-us/windows/wsl/install-win10
Docker for WSL2: docs.docker.com/docker-for-windows/wsl/
What is WSL? docs.microsoft.com/en-us/windows/wsl/about
WSL documentation: docs.microsoft.com/en-us/windows/wsl/
WSL 2 Announcement: devblogs.microsoft.com/commandline/announcing-wsl-2/
Hi David! What if I need several port available in my wsl-based OS? In my case I need 26257 and 8080 ports. How can access via these if only 3390 will route to my wsl-based OS?
Thanks David, much appreciated. The proxy command was the thing I was unaware of. These WSL2 videos are introducing a bunch of missing pieces that are making what I know already much more useful.
You're very welcome Kevin! Glad the videos are helping :)
Your explanations are very clear. This 2 year old video is still relevant. I'm running Ubuntu on WSL 2 on W11 and your video's saved me a lot of time. Thanks!
David, thank you very much! I had a problem developing an application using the Expo platform on WSL 2, and the mobile phone couldn't connect to WSL or Node JS Server, with your video I was able to understand how the network works on WSL2 and used the netsh command to free the application ports. Thank you so much!
I like how you show everyone the documentation you use. Great way to teach.
Excellent video, the way you explained the matter in such a simple way plus providing so much valuable info helped me out a lot! Amazing how even after 2 years this is still usable.
I searched around for the complete guide for the process of Getting GUI. Thanks David. I started to learn from you...
Absolutely love your videos, just coming back from 12 years away from Linux. Your videos are fantastic!!
Thank you very much!!! this was what was missing for me I managed to configure my development environment in react-native in wsl2. I was days trying to connect the Axios backend to port 10.0.2.2:3333 with the Android Studio avd emulator 2 days ago and I hadn't been able to. I tried many things without success and now this video was what was missing, and that made it successful. Thank you very much.
Theachers like you are not easy to find in the 🌎
Thanks 👏👏👏👏👏
Thank you Keivan!
Thank you again David. This video unleashes new possibilities for WSL2. Fine work you do getting this information and explaining to us. Again Saludos desde México.
Thank you for this! I have been trying to get WSL2 to work with VS Code Live Server for so long and this solution worked! It was the windows firewall portion I had been missing to allow the port :)
Just used this video to access Immich over local network which I had installed in my WSL 2 Ubuntu. Thanks!
Great ! Many many thanks, I was struggling with these stuff. Thank you David.
Great explanation David. The beginning was redundant but it works fine to emphasis what IP comes from what node in the network. I would add that this mostly work as it is described but in scenarios when you are using a free port and not reserved like port 80(HTTP) which requires additional steps to get openned
This is great just what I was looking for, thanks David
Thank you. Glad the video helped you :)
Your explanation was amazing. I appreciate your content. Thank you, mate!
Very detailed tutorial 👍 Thank you sir!
Great video tutorial about WSL networking, I learned lot's of from your tutorials. Thanks.
Hi David! Your explanation was useful for me , and now I can execute my django web app from the Ubuntu app for Windows 10 and access to the app from my Android device!! Thank you very much!!!!😄👍👍
Where were you till now :) I loved your videos. So much best explained content.. May god Bless you and you be a biggest youtuber.
Big fan david sir!!! Learned a lot from this video looking forward to learn something new from you again 😊
Thank you Sameer
Great video David thanks for the info. I was able to answer my own question by watching your previous video. Thanks again for all the hard work .....
thanks David you improved my knowledge.
You are welcome Prasanna
Thank you for such an easy to follow tutorial.
This was fantastic. Thanks David !
David, I am from Indonesia..I am new follower u..nice to meet this ..coz your explanation is always clear
Genius!! Thank you very much. So many hours wasted until I reach your video.
I watched the whole video just to figure out I needed to turn off my firewall. Thank you
Thank you, David. You literally save my day!
This is a great video. I'm new to the whole WSL 2 environment, cause I've been using VMware, but I'll be trying this out on my other laptops for sure. Thanks for the video David, much appreciated. ;-)
thank you for writing the command we all came to get on the comments. you are the one.
I clarify several doubts that I had. Thanks a lot !!.🙌
everything i needed thank you so so so much!!!
Thanks David, for the clear explanation, you're an rockstart😍⭐⭐
Thanks so much, this video really helped me. I was building ReactJS app inside WSL 2 and wanted to test the app an other computer
Thanks for that awsome tutorial!! finally :) good explained. now i can finally connect remote to my wsl machines :)
I LOVE YOUR CHANNEL!!! you are amazing! Thanks
David is the Bomb... All! Thanks David 👌
Greetings from Brazil! Super content!
You saved my life! Thanks
Excellent video.
Thanks a lot david. You are such an idol for me. Love from india🇮🇳
Thank you!
David - great video! thank you.
Great video, man. Thx for save us
Absolutely loving this
Thanks David, really appreciated.
ABSOLUTLY A W S O M E !! that was exactly what I was looking for and also the links you provided were the ones I landed on while searching the web!!!
THANK YOU (all Educational-youtubers) FOR YOUR TIME AND ENERGY in DOING THIS! As usual the walkthrough and the explanations are PERFECT and crystal clear for anybody!
WE LUV U D.Bomb
Great video David!
This helped a lot thank you!
YOU ARE AN ABSOLUTE SAINT, I CANNOT THANK YOU ENOUGH FOR THIS TUTORIAL MAN!
OH WOOOOOOOOOOOOOOOOOOOOW
you are the best, now i can watch plex locally on my tv so I wont lose quality
Thanks for the video!
Nice work of explanation.
You helped me a lot, thank you!
Amazing video!
That's what I've been wondering why I couldn't ping my wsl2 ubuntu distro thank you very much David this has been helpful
Really happy to hear that Michael. Yes, a bit of a paradigm shift this... but you are basically doing networking and running firewalls within Windows :)
@@davidbombal Thank you David
thanks helped me a lot in my web development
Appreciate your help with networking on WSL2. Just sub'd thanks!
Came here after researching and hitting the GH issues etc.
Good explanation. I only wish it wouldn't be such a pita -.-
I already have Shayne's hacks in place, had it for WSL1 too.
I needed WSL2 for docker & they take away bridge mode; that's ludicrous.
On the verge of just switching to Linux all by itself. xD
thank your for this video, never disappointed
thanks a lot man, you saved my life! :)
Thanks so much David ❤️
Thank you Ibrahim
Thanks this help me a lot.
Thanks dad! Didn't skip an ad.
I appreciate that!
Thank you a lot, you made my day
Amazing video! Thank you David
Glad you liked it!
@@davidbombal :D
Good content. Thank You Sir
Thank you Ganesh
Option 2: Bridge mode
Solution: Switch from NAT to Bridge mode
WSL2 comes by default in NAT mode. There the wsl2 system has another ip in another subnet than the host. The PC is from external peers only visible by the windows IP and the wsl2 ip/net is hidden/internal. So all traffic would need to be accepted by the windows IP and then forwarded to the wsl2 ip (port forwarding).
There is another mode called bridge mode. In bridge mode your network interface card will be shared to the wsl2 system, and it will get its own IP/Net in wsl2. So in effect your network card is shared to both systems (windows / wsl2) and will have two IPs, as if you'd have two systems with its own network card each. Cool thing: You will never have port conflicts when Windows uses the same port as well, as your wsl2 app (like 111).
Enable bridge mode
Open Hyper-V Manager as administrator
Select your pc, open Virtual Switch Manager
Select WSL
Set to external network
Select the network card the traffic runs through
Then login to wsl2 terminal and configure an IP address. E.g.
sudo ip addr add 192.168.0.116/24 dev eth0
You need to use another free IP (not your Windows IP). If your network has a DHCP server your wsl can get one by:
sudo ip addr flush dev eth0
sudo dhclient eth0
make sure to start / enable the xrdp service in your linux desktop else you will not be able to start an RDP session.
How does this work in regards to the wsl reroling a new IP on host machine reboot
everytime you start wsl2 it will remake the wsl virtual switch and have it set to incorrect.. i tried script in vid and still not reachable
you are a life saver.
Thanks for your sharing 👍
Hi David thanks for the valuable information. I have a question when I connect cisco VPN in local laptop there is network connectivity issues inside WSL2 please help on this
I love you so much man!!!
Thank You so much I have been trying to crack it since 2 days.. Finally it worked.. thanks
Thanks David!
Hi David.Thanks for every thinge you are doing in Yourube Or Udemy.
I passed My CCNA today 😂😂😂.
Fantastic! Congratulations!
you save my life 🥺
I honestly wanted to slap myself after trying this for every evening for three days and only after reaching today Firewall Rules did I figure out why everything I was trying was not working. That should have been step 5!
Thank you David for yet another great video! I was wondering if it is possible to connect your Windows 10 Home laptop with an ethernet cable and then create vlans on the laptop interface (as a trunk interface) and assign each WSL2 virtual machine (ubuntu instances) on a different vlan. Did you happen to come across such an information during your research on WSL2?
i like your network speed
Thanks, David. A wonderful series on WSL2! I have a question. Is it possible to have more than 1 Linux on a Windows 10, and have all the three connected? Possibly on the same subnet? Suppose I have Ubuntu and Kali on the same Windows 10.
thanks you are the best of the best
LIFE SAVER!
so helpful
I've been thinking 'bout networking on wsl2 for last two days... and now this video is in my subs. This is some illuminati level, lmao. Thank you, btw.
lol... I'm reading your mind :)
thx so much sir
David, it would be very good if you made a video about the interaction between 2 WSL VM in order to test, for example, kali tools vs ubuntu. In order to do that, the 2 VMs need to have 2 different IP addr in the same subnet (connected to the same vshiwtch) or with different IP subnet routable through the windows host (I dont know if it is posible). When you boot 2 WSL VMs, they have the same IP addr, it is like if they were connected to different vshwitch with the same ip subnet but with the same default Gateway. It is also extrange to me that the MAC address in the ARP table of the windows host, is the same for both VMs. Thanks and sorry for my english.
another question since you're on the topic on networking. How do you access local host on WSL2? From my searches it seems its not as intuitive as just using "localhost" like in WSL. So currently can't do database on a windows hosted database from WSL2.
Very nice tutorial, David!. I used it to configure ssh access from a chromebook to Ubuntu in a WSL and I managed to get it working. Thanks!!! I have to run the netsh command everytime but it's ok for me. One question: Is it safe to have the port 22 open in Windows Firewall Defender (with Public domain unchecked?) Thanks again for your help. Cheers!
hello david.
since the dynamic IP for the WSL VM changes every boot, wouldn't it be easier to instead NAT the port to the localhost IP? since, as we can see at 4:45 it also works.
this way you don't need to bother with scripts.
another option, wouldn't it be possible to force the IP to be static from the VM side? with the usual ifcfg-eth0 file.
Hi David thanks for the video, What I was wondering is that is there a GNS3 VM in WSL2 virtual machine that I could use to integrate in GNS3 or EVE-NG WSL 2 instead of using vmware player?
#excellent vids
Thank you for these clear and informative videos on WSL2. This is the first time that I seriously look into the WSL subsystem and I am a bit puzzled and somewhat disillusioned so far. I have been using virtual machines with VMware and VirtualBox for over 10 years and I am still wondering what the real benefits of using WSL2 are compared to for instance VMWare Workstation or VirtualBox. To me both Hyper-V and WSL2 seems so unfinished and "raw", and to be honest, quite a mess in comparison to the alternatives. Having the option of setting up Bridged, NAT, HostNIC sharing etc is a must in my world. Having to deal with changing IPs, firewall rules for every virtual environment seems too much. What ARE the real benefits of using WSL2 really?
Only benefit i saw is it consumes less RAM but like you said it is impossible for me to do things without network bridging. And from what i saw it doesn't have snapshots which is a must for a test & dev. environment.
Cheers Mate
Thank you!
Hi David, Thanks for this. Where do you run that PS script from? From your host machine or from your WSL2 Ubuntu machine? I would assume it would be from my host machine which is Windows 10
Have you tried bridging the vEthernet interface to your physical one and then just trying DHCP on the WSL2 guest?
If you just want to run the X desktop remotely, you could use remote desktop to the Windows 10 host and then use remote desktop from the Windows 10 host to localhost:3390. I haven't tried it yet, but couldn't you modify the WSL virtual adapter using the Virtual Switch Manager to change it to an external network?
Thanks David,
have a question:
Do you know how to configure a static ip address to the wsl2 ubuntu
David, did you experience problems with your Armoury Crate after enabling virtualization on your BIOS? Because when I turned on virtualization on my BIOS, it stopped Armoury from gathering hardware information, like CPU temperature and such. Did you experience the same problem on you ASUS? Can you please speak to this issue?