From 8f23d2f2349a48413a98c330333eb14937f48024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20Emil=20Fetoiu?= Date: Wed, 21 Jun 2023 17:23:07 -0700 Subject: [PATCH] Add networking diagnostics to collect-wsl-logs script (#10180) Add netwokring diagnostics to collect-wsl-logs script and additional commands to networking.sh --------- Co-authored-by: Catalin-Emil Fetoiu Co-authored-by: Mitchell Schmidt <74631052+mitschmi@users.noreply.github.com> --- diagnostics/collect-wsl-logs.ps1 | 73 ++++++++++++++++++++++++++++++++ diagnostics/networking.sh | 4 +- 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/diagnostics/collect-wsl-logs.ps1 b/diagnostics/collect-wsl-logs.ps1 index c183562..694f9c6 100644 --- a/diagnostics/collect-wsl-logs.ps1 +++ b/diagnostics/collect-wsl-logs.ps1 @@ -130,6 +130,79 @@ if ($Dump) } } +# Collect networking state relevant for WSL +# Using a try/catch for commands below, as some of them do not exist on all OS versions + +Write-Host "`nCollecting additional network state..." + +$networkingFolder = "$folder/networking" +mkdir -p $networkingFolder + +# Host networking info +try +{ + Get-NetAdapter -includeHidden | select Name,ifIndex,NetLuid,InterfaceGuid,Status,MacAddress,MtuSize,InterfaceType,Hidden,HardwareInterface,ConnectorPresent,MediaType,PhysicalMediaType | Out-File -FilePath "$networkingFolder/Get-NetAdapter.log" -Append +} +catch {} + +try +{ + Get-NetIPConfiguration -All -Detailed | Out-File -FilePath "$networkingFolder/Get-NetIPConfiguration.log" -Append +} +catch {} + +try +{ + Get-NetFirewallHyperVVMCreator | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVVMCreator.log" -Append +} +catch {} + +try +{ + Get-NetFirewallHyperVVMSetting -PolicyStore ActiveStore | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVVMSetting_ActiveStore.log" -Append +} +catch {} + +try +{ + Get-NetFirewallHyperVProfile -PolicyStore ActiveStore | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVProfile_ActiveStore.log" -Append +} +catch {} + +try +{ + Get-NetFirewallHyperVPort | Out-File -FilePath "$networkingFolder/Get-NetFirewallHyperVPort.log" -Append +} +catch {} + +try +{ + & hnsdiag.exe list all 2>&1 > $networkingFolder/hnsdiag_list_all.log +} +catch {} + +try +{ + & hnsdiag.exe list endpoints -df 2>&1 > $networkingFolder/hnsdiag_list_endpoints.log +} +catch {} + +try +{ + foreach ($port in Get-NetFirewallHyperVPort) + { + & vfpctrl.exe /port $port.PortName /get-port-state 2>&1 > "$networkingFolder/vfp-port-$($port.PortName)-get-port-state.log" + & vfpctrl.exe /port $port.PortName /list-rule 2>&1 > "$networkingFolder/vfp-port-$($port.PortName)-list-rule.log" + } +} +catch {} + +try +{ + & vfpctrl.exe /list-vmswitch-port 2>&1 > $networkingFolder/vfpctrl_list_vmswitch_port.log +} +catch {} + $logArchive = "$(Resolve-Path $folder).zip" Compress-Archive -Path $folder -DestinationPath $logArchive Remove-Item $folder -Recurse diff --git a/diagnostics/networking.sh b/diagnostics/networking.sh index ec563c1..d60931a 100644 --- a/diagnostics/networking.sh +++ b/diagnostics/networking.sh @@ -13,7 +13,9 @@ uname -a # Output adapter & routing configuration. ip a -ip route show +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