Saturday 24 September 2022

Ping not working in WSL2 Kali Linux

 I found the answer here:

           sudo setcap cap_net_raw+ep /usr/bin/ping

Issues with WSL2 Networking

 WSL2 networking continues to be problematic, be it DNS not working or network connectivity being lost with the wider network. I also had an issue where WSL2 seemed to prefer a disconnected WiFi connection over a connected Ethernet one.

Things I have done:

1. Disable the unused WiFi Adaptor, this has prevented WSL2 from trying to use it.

2. Turned off Windows Fast Start - This is accessed from the power butttons options underneath power plan. Apparantly it helps fix issues if you shutdown\startup the machine with WSL2 rather than restart.

3. Configured static DNS for WSL2 machines. I created a /etc/wsl.conf file containing the following (replace the name servers with what you want): 
            [network]
            generateResolvConf = false
            nameserver 192.168.1.3
            nameserver 192.168.1.4

4. Networking still craps out but I find this network stack reset recommendation from stackOverflow helps:
            wsl --shutdown
            netsh winsock reset
            netsh int ip reset all
            netsh winhttp reset proxy
            ipconfig /flushdns
            Windows Search > Network Reset
            Restart Windows