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
  • НаукаНаука

Комментарии • 293

  • @davidbombal
    @davidbombal  4 года назад +28

    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/

    • @gijduvon6379
      @gijduvon6379 3 года назад

      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?

  • @networktastic
    @networktastic 4 года назад +14

    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.

    • @davidbombal
      @davidbombal  4 года назад +1

      You're very welcome Kevin! Glad the videos are helping :)

  • @rudiklein
    @rudiklein Год назад +2

    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!

  • @victorbacega9699
    @victorbacega9699 3 года назад +3

    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!

  • @DominicFlynn
    @DominicFlynn 2 года назад +1

    I like how you show everyone the documentation you use. Great way to teach.

  • @011sale
    @011sale Год назад

    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.

  • @uday_kiran
    @uday_kiran 2 года назад

    I searched around for the complete guide for the process of Getting GUI. Thanks David. I started to learn from you...

  • @bdubs2437
    @bdubs2437 2 года назад

    Absolutely love your videos, just coming back from 12 years away from Linux. Your videos are fantastic!!

  • @georgealan7772
    @georgealan7772 3 года назад +2

    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.

  • @keivan_adak
    @keivan_adak 4 года назад +11

    Theachers like you are not easy to find in the 🌎
    Thanks 👏👏👏👏👏

  • @sergiomancera9225
    @sergiomancera9225 4 года назад

    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.

  • @TAVG333
    @TAVG333 Год назад

    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 :)

  • @bharcooldude
    @bharcooldude 4 месяца назад +1

    Just used this video to access Immich over local network which I had installed in my WSL 2 Ubuntu. Thanks!

  • @bekman95
    @bekman95 2 года назад +1

    Great ! Many many thanks, I was struggling with these stuff. Thank you David.

  • @vtgus
    @vtgus 3 года назад

    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

  • @ThePumbaadk
    @ThePumbaadk 4 года назад +3

    This is great just what I was looking for, thanks David

    • @davidbombal
      @davidbombal  4 года назад

      Thank you. Glad the video helped you :)

  • @jbenini
    @jbenini 5 месяцев назад

    Your explanation was amazing. I appreciate your content. Thank you, mate!

  • @orleydoss3171
    @orleydoss3171 4 года назад

    Very detailed tutorial 👍 Thank you sir!

  • @BenjaminBiswas
    @BenjaminBiswas 2 года назад +1

    Great video tutorial about WSL networking, I learned lot's of from your tutorials. Thanks.

  • @gastonsalaya
    @gastonsalaya 3 года назад

    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!!!!😄👍👍

  • @sumitsrivastava1021
    @sumitsrivastava1021 Год назад

    Where were you till now :) I loved your videos. So much best explained content.. May god Bless you and you be a biggest youtuber.

  • @abdulsamihamedi5584
    @abdulsamihamedi5584 4 года назад +6

    Big fan david sir!!! Learned a lot from this video looking forward to learn something new from you again 😊

  • @michaelcooper5490
    @michaelcooper5490 2 года назад

    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 .....

  • @prasannakumara6987
    @prasannakumara6987 4 года назад +4

    thanks David you improved my knowledge.

  • @nokswift
    @nokswift 2 года назад

    Thank you for such an easy to follow tutorial.

  • @cloudtech273
    @cloudtech273 2 года назад

    This was fantastic. Thanks David !

  • @mevitu
    @mevitu 3 года назад

    David, I am from Indonesia..I am new follower u..nice to meet this ..coz your explanation is always clear

  • @askanioff
    @askanioff Год назад

    Genius!! Thank you very much. So many hours wasted until I reach your video.

  • @davidwarshawsky1559
    @davidwarshawsky1559 Год назад

    I watched the whole video just to figure out I needed to turn off my firewall. Thank you

  • @user-go9zr4jk4o
    @user-go9zr4jk4o Год назад

    Thank you, David. You literally save my day!

  • @KennyGJr
    @KennyGJr 3 года назад

    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. ;-)

  • @agusttt
    @agusttt 3 года назад

    thank you for writing the command we all came to get on the comments. you are the one.

  • @cuberos7430
    @cuberos7430 2 года назад

    I clarify several doubts that I had. Thanks a lot !!.🙌

  • @shervinrad100
    @shervinrad100 3 года назад +1

    everything i needed thank you so so so much!!!

  • @pasanmadhuranga9545
    @pasanmadhuranga9545 2 месяца назад

    Thanks David, for the clear explanation, you're an rockstart😍⭐⭐

  • @somaliya
    @somaliya 2 года назад

    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

  • @DomThePsy
    @DomThePsy 2 месяца назад

    Thanks for that awsome tutorial!! finally :) good explained. now i can finally connect remote to my wsl machines :)

  • @asaf158
    @asaf158 3 года назад

    I LOVE YOUR CHANNEL!!! you are amazing! Thanks

  • @DemolaOkesola
    @DemolaOkesola 4 года назад

    David is the Bomb... All! Thanks David 👌

  • @GuisepeCamoli
    @GuisepeCamoli 3 года назад

    Greetings from Brazil! Super content!

  • @murilo.goedert
    @murilo.goedert Год назад

    You saved my life! Thanks

  • @patricio0
    @patricio0 10 месяцев назад

    Excellent video.

  • @rishabhtomar2174
    @rishabhtomar2174 4 года назад +1

    Thanks a lot david. You are such an idol for me. Love from india🇮🇳

  • @kindalost1
    @kindalost1 2 года назад

    David - great video! thank you.

  • @luisfelipedasilva7128
    @luisfelipedasilva7128 Год назад

    Great video, man. Thx for save us

  • @zihaosong1514
    @zihaosong1514 3 года назад

    Absolutely loving this

  • @dominiquerakotonirina5697
    @dominiquerakotonirina5697 Год назад

    Thanks David, really appreciated.

  • @azelbane87
    @azelbane87 3 года назад +3

    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

  • @alfonsojosemateoshoyos7615
    @alfonsojosemateoshoyos7615 3 года назад

    Great video David!

  • @snowblindu
    @snowblindu Месяц назад

    This helped a lot thank you!

  • @hambaku7318
    @hambaku7318 3 года назад +3

    YOU ARE AN ABSOLUTE SAINT, I CANNOT THANK YOU ENOUGH FOR THIS TUTORIAL MAN!
    OH WOOOOOOOOOOOOOOOOOOOOW

  • @xaviercruzPT
    @xaviercruzPT Год назад

    you are the best, now i can watch plex locally on my tv so I wont lose quality

  • @vladislavkaras491
    @vladislavkaras491 Год назад

    Thanks for the video!

  • @bouhannacheabdallah
    @bouhannacheabdallah 3 года назад

    Nice work of explanation.

  • @PedrodosSantosPereira
    @PedrodosSantosPereira 3 года назад

    You helped me a lot, thank you!

  • @Magotek8416
    @Magotek8416 Год назад

    Amazing video!

  • @michaelanderson7902
    @michaelanderson7902 4 года назад

    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

    • @davidbombal
      @davidbombal  4 года назад +1

      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 :)

    • @michaelanderson7902
      @michaelanderson7902 4 года назад

      @@davidbombal Thank you David

  • @Siddid
    @Siddid 2 года назад +1

    thanks helped me a lot in my web development

  • @erusman727
    @erusman727 3 года назад

    Appreciate your help with networking on WSL2. Just sub'd thanks!

  • @Xewl
    @Xewl 3 года назад

    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

  • @fabrice9848
    @fabrice9848 3 года назад

    thank your for this video, never disappointed

  • @Lipe007_br
    @Lipe007_br 3 года назад

    thanks a lot man, you saved my life! :)

  • @ibrahimabdeltawab6418
    @ibrahimabdeltawab6418 4 года назад +1

    Thanks so much David ❤️

  • @naninca
    @naninca Год назад

    Thanks this help me a lot.

  • @mariembuenaventura1278
    @mariembuenaventura1278 4 года назад

    Thanks dad! Didn't skip an ad.

  • @NGANguyenBinhVTID
    @NGANguyenBinhVTID 27 дней назад

    Thank you a lot, you made my day

  • @amarashfaq8359
    @amarashfaq8359 4 года назад

    Amazing video! Thank you David

  • @ganeshchippa1
    @ganeshchippa1 4 года назад +1

    Good content. Thank You Sir

  • @Michaelmaertzdorf
    @Michaelmaertzdorf 4 года назад +2

    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.

    • @null_phase
      @null_phase 3 года назад

      How does this work in regards to the wsl reroling a new IP on host machine reboot

    • @null_phase
      @null_phase 3 года назад

      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

  • @user-qo9ho8oj7k
    @user-qo9ho8oj7k Год назад

    you are a life saver.

  • @allezvenga7617
    @allezvenga7617 4 года назад

    Thanks for your sharing 👍

  • @SachinKumar-qk9yu
    @SachinKumar-qk9yu 3 года назад +6

    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

  • @sahilsagwekar
    @sahilsagwekar 11 месяцев назад

    I love you so much man!!!

  • @jaromirvalek8120
    @jaromirvalek8120 Год назад

    Thank You so much I have been trying to crack it since 2 days.. Finally it worked.. thanks

  • @wingwing2683
    @wingwing2683 2 года назад

    Thanks David!

  • @waasabbas
    @waasabbas 4 года назад

    Hi David.Thanks for every thinge you are doing in Yourube Or Udemy.
    I passed My CCNA today 😂😂😂.

  • @arriyari
    @arriyari Год назад

    you save my life 🥺

  • @robisadev
    @robisadev 7 месяцев назад

    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!

  • @konstantinosvlitakis
    @konstantinosvlitakis 4 года назад

    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?

  • @fruitsbasket6141
    @fruitsbasket6141 3 года назад

    i like your network speed

  • @FajarSuryawan
    @FajarSuryawan 3 года назад +1

    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.

  • @jlocana1
    @jlocana1 3 года назад

    thanks you are the best of the best

  • @alexandrecaldeira9522
    @alexandrecaldeira9522 3 года назад

    LIFE SAVER!

  • @user-uu1bx4xv1s
    @user-uu1bx4xv1s 3 года назад

    so helpful

  • @taras1783
    @taras1783 4 года назад +2

    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.

    • @davidbombal
      @davidbombal  4 года назад

      lol... I'm reading your mind :)

  • @zeonsoulon4433
    @zeonsoulon4433 3 года назад

    thx so much sir

  • @alejandrorodriguez3771
    @alejandrorodriguez3771 3 года назад +3

    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.

  • @edwardhoffenheim3249
    @edwardhoffenheim3249 4 года назад +1

    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!

  • @BattousaiHBr
    @BattousaiHBr 4 года назад

    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.

  • @umairm8595
    @umairm8595 4 года назад

    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?

  • @ctoxyz
    @ctoxyz Год назад

    #excellent vids

  • @bunkermagnus
    @bunkermagnus 3 года назад +4

    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?

    • @rottenfist220
      @rottenfist220 2 года назад

      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.

  • @refaiabdeen5943
    @refaiabdeen5943 Год назад

    Cheers Mate

  • @nsteblay
    @nsteblay 3 года назад

    Thank you!

  • @AbulHasanLakhani
    @AbulHasanLakhani 3 года назад

    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

  • @NicolaiSyvertsen
    @NicolaiSyvertsen 4 года назад +1

    Have you tried bridging the vEthernet interface to your physical one and then just trying DHCP on the WSL2 guest?

  • @badpants
    @badpants 4 года назад

    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?

  • @gabrielcastro832
    @gabrielcastro832 3 года назад +1

    Thanks David,
    have a question:
    Do you know how to configure a static ip address to the wsl2 ubuntu

  • @dariosilva85
    @dariosilva85 3 года назад +1

    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?