diff --git a/diagnostics/networking.bat b/diagnostics/networking.bat index 8c3ab595..29295903 100644 --- a/diagnostics/networking.bat +++ b/diagnostics/networking.bat @@ -1,38 +1,38 @@ @echo off :: Note: This script terminates WSL. Save your work before running it. -:: Check for administrator access +:: Check for administrator privileges. net session >nul 2>&1 || goto :admin -:: Validate that required files are here +:: 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) -:: List installed Windows features +:: List installed Windows features. echo Windows features: powershell.exe -NoProfile "Get-WindowsOptionalFeature -Online | ? State -eq Enabled | select FeatureName" -:: List all HNS objects +:: List all HNS objects. echo HNS objects: hnsdiag list all -df -:: Print the Windows routing table +:: 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 +:: 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 +:: Stop WSL. net.exe stop LxssManager -:: Start packet capture +:: 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 +:: Collect WSL logs. wpr -start wsl_networking.wprp -filemode || goto :fail wsl.exe tr -d "\r" ^| bash < ./networking.sh @@ -41,11 +41,13 @@ powershell -NoProfile "Stop-NetEventSession HnsPacketCapture; Remove-NetEventSe exit /b 0 +:: Error message if the WSL logs fail to collect. :fail -echo Failed to collect WSL logs +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 access -exit /b 1 \ No newline at end of file +echo This script needs to run with administrative privileges. +exit /b 1 diff --git a/diagnostics/networking.sh b/diagnostics/networking.sh index e9b17a34..070ed4ef 100644 --- a/diagnostics/networking.sh +++ b/diagnostics/networking.sh @@ -7,30 +7,30 @@ fi set -xu -# Gather distro & kernel info +# Gather distro & kernel info. lsb_release -a || cat /etc/issue /etc/os-release uname -a -# Output adapter & routing configuration +# Output adapter & routing configuration. ip a ip route show -# Validate that the gateway is responsive and can route ICMP correctly +# 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' + 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) +# Validate that the default route is working (won't work if traceroute isn't installed). traceroute 1.1.1.1 -# Display the DNS configuration +# Display the DNS configuration. cat /etc/resolv.conf -# Validate that everything is functionning correctly +# Validate that everything is functionning correctly. if type curl >/dev/null 2>&1; then curl -m 5 -v https://microsoft.com else