0

I'm using WSL2 (Ubuntu 22.04) and Windows 11 Education 24H2.

I've checked my BIOS settings, and virtualization is enabled. Hyper-V is turned on, and I've tried disabling and enabled it and restarting my computer in between. I've tried turning off my firewall, and it doesn't make a difference. I checked my %temp%, and it doesn't appear to have been compressed.

I have a laptop on the same network with the same (automatically generated) /etc/resolv.conf that can ping Google in WSL2 and run sudo apt-get update, so I don't think the generated config is the issue, but I did try changing my wsl.conf and resolv.conf (although I'm open to trying again).

I've tried setting swap=0, networkingMode=mirrored, dnsProxy=false, localhostforwarding=true, dnsTunneling=true, bestEffortDnsParsing=true, firewall=false, autoProxy=true, and they've all been whatever the default is as well. I also looked at https://github.com/microsoft/WSL/issues/4150 this post and attempted it, but I'm not sure I was able to complete the steps successfully as it said:

Remove-NetFireWallRule : No MSFT_NetFirewallRule objects found with property 'DisplayName' equal to 'WSL 2 Firewall
Unlock'.  Verify the value of the property and retry.
At line:1 char:1
+ Remove-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (WSL 2 Firewall Unlock:String) [Remove-NetFirewallRule], CimJobException
    + FullyQualifiedErrorId : CmdletizationQuery_NotFound_DisplayName,Remove-NetFirewallRule

and The system cannot find the file specified.

I do think it might be a firewall problem as opposed to a wsl.conf problem though because when I try to ping www.google.com it says PING www.google.com (172.217.1.100) 56(84) bytes of data. So it can resolve www.google.com to an address, right? And the problem is just that no packets make it through.

Also, if I do an ipconfig in Powershell, I can see that there are IPv4 addresses for Wireless LAN adapter Wi-Fi, Ethernet adapter vEthernet (Default Switch), and Ethernet adapter vEthernet (WSL (Hyper-V firewall)), and I can ping all of those from PowerShell, but I can only successfully ping the Ethernet adapter vEthernet (WSL (Hyper-V firewall)) address in WSL2.

Finally, if I restart my computer and then open WSL and ping www.google.com, about 2-6 pings will make it through before it stops... and sometimes another 2-6 will make it through a few seconds later before packets completely stop being returned/delivered.

But again, I've tried disabling my Windows firewall, and it didn't make a difference in terms of pinging. I've been working on this for three days and have no idea what's wrong TT I tried switching to WSL1 earlier, and that worked, but I had trouble doing an npx install (because I think it got confused with Windows paths) :'( Also, I'd just like to be able to use WSL2 because it should work and I have no idea why it doesn't.

Ramhound
  • 44,080

1 Answers1

0

I've answered this question in one other location: I am not sure where is the most appropriate place to answer, but this worked for me!

I had the same issue where a local internet ip was set up in my wsl, and restarting caused it to be re-added....

I found launching from powershell with debian.exe was better than with wsl.exe for some unknown reason: I did check, and it is the same instance.

Resolved this by modifying two files: sudo nano /etc/resolv.conf needed the nameserv removed and changed to 1.1.1.1 or 8.8.8.8 (probably would be okay to remove it all together, may even be okay to keep it--still testing--.

So, it should look like this:

nameserv 1.1.1.1

And it's also worth noting I had to do this:

cd /etc
sudo nano resolv.conf

Because sudo nano /etc/resolv.conf resulted in "directory does not exist" errors at the bottom of nano.

The second one might be the only one that was necessary: I used sudo nano /etc/wsl.conf and had to add

[network]
generateResolvConf = false

You could also add permissions so you won't need to use sudo just to ping....

which ping
sudo visudo
your_username ALL=(ALL) NOPASSWD: etc/bin/ping 

You add the third line to the visudo file. Yes, you need the full address of the executable which is seen via which.

Wolfpack'08
  • 1,364