Skip to content

Commit

Permalink
Add networking diagnostics to collect-wsl-logs script (#10180)
Browse files Browse the repository at this point in the history
Add netwokring diagnostics to collect-wsl-logs script and additional commands to networking.sh

---------

Co-authored-by: Catalin-Emil Fetoiu <[email protected]>
Co-authored-by: Mitchell Schmidt <[email protected]>
  • Loading branch information
3 people authored Jun 22, 2023
1 parent 73fde8b commit 8f23d2f
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
73 changes: 73 additions & 0 deletions diagnostics/collect-wsl-logs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion diagnostics/networking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8f23d2f

Please sign in to comment.