diff --git a/diagnostics/networking.bat b/diagnostics/networking.bat
deleted file mode 100644
index 2d6ee0f..0000000
--- a/diagnostics/networking.bat
+++ /dev/null
@@ -1,57 +0,0 @@
-@echo off
-:: Note: This script terminates WSL. Save your work before running it.
-
-:: Check for administrator privileges.
-net session >nul 2>&1 || goto :admin
-
-:: Validate that required files are here.
-if not exist wsl_networking.wprp (echo wsl_networking.wprp not found && exit /b 1)
-if not exist networking.sh (echo networking.sh not found && exit /b 1)
-
-:: Capture the store WSL version
-echo "WSL version (Might be help text if store WSL is not installed):"
-wsl.exe --version
-
-:: List installed Windows features.
-echo Windows features:
-powershell.exe -NoProfile "Get-WindowsOptionalFeature -Online | ? State -eq Enabled | select FeatureName"
-
-:: List all HNS objects.
-echo HNS objects:
-hnsdiag list all -df
-
-:: Print the Windows routing table.
-echo Routing table:
-netstat.exe -rn
-
-:: The WSL HNS network is created once per boot. Resetting it to collect network creation logs.
-echo Deleting HNS network
-powershell.exe -NoProfile "Get-HnsNetwork | Where-Object {$_.Name -eq 'WSL'} | Remove-HnsNetwork"
-
-:: Stop WSL.
-net.exe stop WslService || net.exe stop LxssManager
-
-:: Start packet capture.
-powershell.exe -NoProfile "New-NetEventSession HnsPacketCapture -CaptureMode SaveToFile -LocalFilePath %cd%\\packets.etl" || goto :fail
-powershell.exe -NoProfile "Add-NetEventPacketCaptureProvider -Level 5 -SessionName HnsPacketCapture -CaptureType BothPhysicalAndSwitch " || goto :fail
-powershell.exe -NoProfile "Start-NetEventSession HnsPacketCapture" || goto :fail
-
-:: Collect WSL logs.
-wpr -start wsl_networking.wprp -filemode || goto :fail
-wsl.exe tr -d "\r" ^| bash < ./networking.sh
-
-wpr -stop wsl.etl || goto :fail
-powershell -NoProfile "Stop-NetEventSession HnsPacketCapture; Remove-NetEventSession HnsPacketCapture" || goto :fail
-
-exit /b 0
-
-:: Error message if the WSL logs fail to collect.
-:fail
-echo Failed to collect WSL logs.
-powershell -NoProfile "Stop-NetEventSession HnsPacketCapture; Remove-NetEventSession HnsPacketCapture"
-exit /b 1
-
-:: Error message if the user does not have administrative privileges.
-:admin
-echo This script needs to run with administrative privileges.
-exit /b 1
diff --git a/diagnostics/networking.sh b/diagnostics/networking.sh
index d60931a..ced04b8 100644
--- a/diagnostics/networking.sh
+++ b/diagnostics/networking.sh
@@ -1,10 +1,4 @@
#! /bin/bash
-if (($(id -u) != 0))
-then
- printf "If you see 'ping: socket: Operation not permitted' errors, "
- printf "run this command as root.\n"
-fi
-
set -xu
# Gather distro & kernel info.
@@ -17,24 +11,5 @@ ip route show table all
ip neighbor
ip link
-# Validate that the gateway is responsive and can route ICMP correctly.
-if gateway=$(ip route show | awk '/default/ { print $3 }'); then
- ping -c 4 "$gateway"
-else
- echo 'No gateway found.'
-fi
-
-ping -c 4 1.1.1.1
-
-# Validate that the default route is working (won't work if traceroute isn't installed).
-traceroute 1.1.1.1
-
# Display the DNS configuration.
cat /etc/resolv.conf
-
-# Validate that everything is functioning correctly.
-if type curl >/dev/null 2>&1; then
- curl -m 5 -v https://microsoft.com
-else
- wget -T 5 -v https://microsoft.com
-fi
diff --git a/diagnostics/networking_diagnostics.bat b/diagnostics/networking_diagnostics.bat
index 2f452e8..f85f8e1 100644
--- a/diagnostics/networking_diagnostics.bat
+++ b/diagnostics/networking_diagnostics.bat
@@ -1,13 +1,31 @@
+:: Check for administrator privileges.
+net session >nul 2>&1 || goto :admin
+
+:: Validate that required files are here.
+if not exist wsl_networking.wprp (echo wsl_networking.wprp not found && exit /b 1)
+if not exist networking.sh (echo networking.sh not found && exit /b 1)
+
set networking_folder=".\networking_logs"
set neworking_logs_zip=".\WslNetworkingLogs.zip"
mkdir %networking_folder%
-wsl.exe tr -d "\r" ^| bash < ./networking.sh > %networking_folder%\wsl_network_configuration_before.log
-powershell Get-NetRoute > %networking_folder%\get_netroute.log
+cd %networking_folder%
-powershell invoke-expression 'cmd /c start powershell -Command { .\collect-wsl-logs.ps1 }'
-powershell invoke-expression 'cmd /c start powershell -Command { "wsl.exe sudo tcpdump -n -i any > tcpdump.log" }'
+IF "%1"=="--stop-wsl" (
+ :: The WSL HNS network is created once per boot. Resetting it to collect network creation logs.
+ echo Deleting HNS network
+ powershell.exe -NoProfile "Get-HnsNetwork | Where-Object {$_.Name -eq 'WSL'} | Remove-HnsNetwork"
+
+ :: Stop WSL.
+ net.exe stop WslService || net.exe stop LxssManager
+)
+
+wsl.exe tr -d "\r" ^| bash < ../networking.sh > wsl_network_configuration_before.log
+powershell Get-NetRoute > get_netroute.log
+
+powershell invoke-expression 'cmd /c start powershell -Command { ..\collect-wsl-logs.ps1 }'
+powershell invoke-expression 'cmd /c start powershell -Command { "wsl.exe -u root sudo tcpdump -n -i any > tcpdump.log" }'
wpr -start .\wsl_networking.wprp -filemode -instanceName wpr_networking
pktmon start -c --flags 0x1A
@@ -16,22 +34,27 @@ netsh wfp capture start
pause
:: allow some time for the user to stop logs in all the spawned shells
-:: (particularly the shell running collect-wsl-logs.ps1 will take a bit to stop)
timeout 20
netsh wfp capture stop
pktmon stop
-wpr -stop %networking_folder%\wsl_networking.etl -instanceName wpr_networking
+wpr -stop wsl_networking.etl -instanceName wpr_networking
-wsl.exe tr -d "\r" ^| bash < ./networking.sh > %networking_folder%\wsl_network_configuration_after.log
+wsl.exe tr -d "\r" ^| bash < ../networking.sh > wsl_network_configuration_after.log
-move tcpdump.log %networking_folder%
-move PktMon.etl %networking_folder%
-move wfpdiag.cab %networking_folder%
-move "*zip" %networking_folder%
+cd ..
+del %neworking_logs_zip%
powershell Compress-Archive -Path %networking_folder% -DestinationPath %neworking_logs_zip%
rmdir /s /q %networking_folder%
-echo "Finished log collection"
\ No newline at end of file
+echo "Finished log collection - please collect the zip archive from the path below"
+powershell Resolve-Path %neworking_logs_zip%
+
+exit /b 0
+
+:: Error message if the user does not have administrative privileges.
+:admin
+echo This script needs to run with administrative privileges.
+exit /b 1
\ No newline at end of file
diff --git a/diagnostics/wsl_networking.wprp b/diagnostics/wsl_networking.wprp
index c7357ce..d3096e8 100644
--- a/diagnostics/wsl_networking.wprp
+++ b/diagnostics/wsl_networking.wprp
@@ -9,17 +9,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -170,17 +215,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+