Skip to content

Commit 5237ea1

Browse files
Filter virtual/filter network adapters by Name and Description in .NET 9/10 (#3309)
* Initial plan * Enable network interface blacklist filtering for .NET 9/10 Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> * Fix lambda expression in network interface filter Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> * Use inclusive terminology for filter patterns Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> * Add WAN Miniport and Wi-Fi Direct Virtual Adapter to filter list Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> * Filter network interfaces by both Name and Description Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> * Update NetworkInterface.cs * Update NetworkInterface.cs * Docs: #3309 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
1 parent de43bc2 commit 5237ea1

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

Source/NETworkManager.Models/Network/NetworkInterface.cs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,25 @@ public sealed class NetworkInterface
2525
{
2626
#region Variables
2727

28-
/* Ref #3286
29-
private static List<string> NetworkInterfacesBlacklist =
28+
/// <summary>
29+
/// List of network interface name patterns to filter out virtual/filter adapters
30+
/// introduced in .NET 9/10. These are typically not actual network interfaces but rather
31+
/// drivers, filters, or extensions attached to real network interfaces.
32+
/// See: https://github.com/dotnet/runtime/issues/122751
33+
/// </summary>
34+
private static readonly List<string> NetworkInterfaceFilteredPatterns =
3035
[
3136
"Hyper-V Virtual Switch Extension Filter",
37+
"Hyper-V Virtual Switch Extension Adapter",
3238
"WFP Native MAC Layer LightWeight Filter",
3339
"Npcap Packet Driver (NPCAP)",
3440
"QoS Packet Scheduler",
3541
"WFP 802.3 MAC Layer LightWeight Filter",
36-
"Ethernet (Kerneldebugger)",
37-
"Filter Driver"
42+
"Ethernet (Kerneldebugger)",
43+
"Filter Driver",
44+
"WAN Miniport",
45+
"Microsoft Wi-Fi Direct Virtual Adapter"
3846
];
39-
*/
4047

4148
#endregion
4249

@@ -74,12 +81,13 @@ public static List<NetworkInterfaceInfo> GetNetworkInterfaces()
7481
(int)networkInterface.NetworkInterfaceType != 53)
7582
continue;
7683

77-
// Check if part of the Name is in blacklist Ref #3286
78-
//if (NetworkInterfacesBlacklist.Any(networkInterface.Name.Contains))
79-
// continue;
80-
81-
//Debug.WriteLine(networkInterface.Name);
82-
//Debug.WriteLine($" Description: {networkInterface.Description}");
84+
// Filter out virtual/filter adapters introduced in .NET 9/10
85+
// Check if the adapter name or description contains any filtered pattern
86+
// See: https://github.com/dotnet/runtime/issues/122751
87+
if (NetworkInterfaceFilteredPatterns.Any(pattern =>
88+
networkInterface.Name.Contains(pattern) ||
89+
networkInterface.Description.Contains(pattern)))
90+
continue;
8391

8492
var listIPv4Address = new List<Tuple<IPAddress, IPAddress>>();
8593
var listIPv6AddressLinkLocal = new List<IPAddress>();

Website/docs/changelog/next-release.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Release date: **xx.xx.2025**
2020
- Migrated from .NET 8.0 (LTS) to .NET 10.0 (LTS).
2121
Upgrade your [.NET Desktop Runtime to version 10.0 (LTS) - x64](https://dotnet.microsoft.com/en-us/download/dotnet/10.0/runtime) before you install this version. [#3229](https://github.com/BornToBeRoot/NETworkManager/pull/3229)
2222

23+
- Starting with .NET 9.0, the behavior of `NetworkInterface.GetAllNetworkInterfaces()` changed — the API now returns all network interfaces (including virtual adapters, WAN Miniport, extensions/drivers, etc.), which can cause additional or unexpected adapters to appear in the `Network Interface` view. This is an intentional change by Microsoft; see [dotnet/runtime#122751](https://github.com/dotnet/runtime/issues/122751) for details. To reduce noise, NETworkManager maintains a blacklist of known unwanted adapters. If you encounter adapters that should be excluded, please report them via the [issue tracker](https://github.com/BornToBeRoot/NETworkManager/issues/new/choose). [#3286](https://github.com/BornToBeRoot/NETworkManager/issues/3286) [#3309](https://github.com/BornToBeRoot/NETworkManager/pull/3309)
24+
2325
- `AWS Session Manager` feature has been removed. The [AWS Session Manager Plugin](https://github.com/aws/session-manager-plugin) is not actively maintained and contains several bugs (e.g. German / Spain keyboard layout issues). The current code base was also difficult to maintain and extend, and I currently have no test environment.
2426
The Sync feature (EC2 instances -> Profiles) has been removed as well, because it was limited to AWS Session Manager only. This will be re-introduced in a future release to support multiple providers (`AWS`, `Azure`, etc.) and more features like `Ping Monitor`, `PuTTY` or `Remote Desktop`.
2527

0 commit comments

Comments
 (0)