microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.06k stars 797 forks source link

Kali-Linux WSL2 is unable to connect to Internet #11748

Closed CurtisDufour closed 2 weeks ago

CurtisDufour commented 3 weeks ago

Windows Version

Microsoft Windows [Version 10.0.19045.4529]

WSL Version

2.2.4.0

Are you using WSL 1 or WSL 2?

Kernel Version

No response

Distro Version

Kali Linux

Other Software

No response

Repro Steps

In Kali Terminal:

sudo apt update - expect connection to repos. Does not.


[sudo] password for kali:
0% [Working]```

**ping 8.8.8.8** - expect ping of Google DNS - Does not work
```PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 172.21.49.232 icmp_seq=1 Destination Host Unreachable
From 172.21.49.232 icmp_seq=2 Destination Host Unreachable
From 172.21.49.232 icmp_seq=3 Destination Host Unreachable
^C
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 0 received, +3 errors, 100% packet loss, time 4149ms
pipe 4```

**ping 127.0.0.1** - ping of localhost works
```ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.158 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.076 ms
^C
--- 127.0.0.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1024ms
rtt min/avg/max/mdev = 0.076/0.117/0.158/0.041 ms```

```ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:15:5d:60:81:3b brd ff:ff:ff:ff:ff:ff
    inet 172.21.49.232/20 brd 172.21.63.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::215:5dff:fe60:813b/64 scope link
       valid_lft forever preferred_lft forever```

 **ip r**
```default via 172.21.48.1 dev eth0 proto kernel
172.21.48.0/20 dev eth0 proto kernel scope link src 172.21.49.232```

**cat /etc/resolv.conf**
```# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
# nameserver 172.21.48.1
nameserver 8.8.8.8
nameserver 8.8.4.4```

**cat /etc/hosts**
```# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateHosts = false
127.0.0.1       localhost
127.0.1.1       DESKTOP-FOM8I03.        DESKTOP-FOM8I03

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters```

**cat /etc/wsl.conf**
```[boot]
systemd=true

[network]
generateResolvConf = false
generateHosts = false``` <-- I turned these off to modify my /etc/resolv.conf and /etc/hosts during my own failed troubleshooting

### on Powershell side:
**ipconfig /all** - look at  vEthernet (WSL) connection

```Ethernet adapter vEthernet (WSL):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::fbe:5123:665d:5c0a%66
   IPv4 Address. . . . . . . . . . . : 169.254.190.131
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . :```

### Expected Behavior

I'm expecting my WSL2 to connect to the internet so that I can run updates and actually use the tools that I installed it to use.

### Actual Behavior

Does not connect to DNS. Does not connect to network besides its own localhost. I cannot figure out any configurations that will allow me to connect it to the internet my host  computer has access to. I think it has to do with the APIPA address and lack of default Gateway on the Windows side of the vEthernet connector, but I have been unable to modify it to make anything happen, and it doesn't look like anyone else out there has ever had this same error. 

### Diagnostic Logs

Troubleshooting results are above.
github-actions[bot] commented 3 weeks ago

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs Download and execute [collect-wsl-logs.ps1](https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1) in an **administrative powershell prompt**: ``` Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1 Set-ExecutionPolicy Bypass -Scope Process -Force .\collect-wsl-logs.ps1 ``` The scipt will output the path of the log file once done. Once completed please upload the output files to this Github issue. [Click here for more info on logging](https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#8-collect-wsl-logs-recommended-method) If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

CurtisDufour commented 3 weeks ago

WslLogs-2024-07-04_11-53-58.zip

github-actions[bot] commented 3 weeks ago
Diagnostic information ``` Detected appx version: 2.2.4.0 ```
jackrdye commented 2 weeks ago

Same issue, this is a major bug! Unable to develop at all due to it. I hired a networking guy to check network ip configurations were correct, and he said all looked good and couldn't figure out why theres an issue.

OneBlue commented 2 weeks ago

/dupe 8365

BatelAhmed commented 1 week ago

Had the same issue. Here is how to fix it:

Go to Windows Terminal run "ipconfig", find your Default Gateway. Then go to WSL Kali and do Do : sudo nano /etc/resolv.conf Edit the "nameserver" address to the Default Gateway Ctrl+S, Ctrl+X sudo apt-update

should work, hope that helped.