Created network interfaces aren't in `get_interfaces` on Windows
I like that this has more features and details than the network-interface crate, but it has problems on Windows.
[package]
name = "testbin"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
netdev = "0.30"
network-interface = "2.0"
tun2 = { version = "3" }
use tun2::{configure, create};
fn main() {
let device = create(configure().tun_name("utun42").up()).unwrap();
for ni in
<network_interface::NetworkInterface as network_interface::NetworkInterfaceConfig>::show()
.unwrap()
{
dbg!(ni.name);
}
for ni in netdev::get_interfaces() {
dbg!(ni.name);
dbg!(ni.friendly_name);
}
drop(device);
}
Running on Linux with cargo b && sudo ./target/debug/testbin gives exactly what I expect,
[src/main.rs:10:9] ni.name = "eth0"
[src/main.rs:10:9] ni.name = "utun42"
[src/main.rs:10:9] ni.name = "lo"
[src/main.rs:13:9] ni.name = "lo"
[src/main.rs:14:9] ni.friendly_name = None
[src/main.rs:13:9] ni.name = "eth0"
[src/main.rs:14:9] ni.friendly_name = None
[src/main.rs:13:9] ni.name = "utun42"
[src/main.rs:14:9] ni.friendly_name = None
But on Windows (cargo r, copy the DLL from https://github.com/tun2proxy/wintun-bindings/tree/master/wintun/bin/amd64 into the /target/debug folder and run cargo r in a privileged shell), I get
[src/main.rs:10:9] ni.name = "utun42"
[src/main.rs:10:9] ni.name = "Ethernet 2"
...
[src/main.rs:13:9] ni.name = "{E5A5F923-716B-487F-B647-0523E95CE909}"
[src/main.rs:14:9] ni.friendly_name = Some(
"Ethernet 2",
)
...
Besides being inconsistent with the name and friendly_name (it should preferably set friendly_name to the same as name if it doesn't exest, so that I don't have to configure around it), it doesn't show "utun42" on windows.
Also, is it possible to look up an interface by ID (I am currently only looking up by name for workaround reasons) instead of needing to iterate through an array?
Thank you for reporting! We’ve recently updated netdev to improve support for unknown interface types and proprietary virtual/internal interfaces (IfType == 53). These changes ensure that interfaces like WireGuard or other similar virtual adapters are now recognized correctly.
To clarify how interface names are handled on Windows:
- name: IP_ADAPTER_ADDRESSES_LH.AdapterName – The unique identifier for the adapter.
- friendly_name: IP_ADAPTER_ADDRESSES_LH.FriendlyName – A human-readable name, if available.
- description: IP_ADAPTER_ADDRESSES_LH.Description – A descriptive string about the adapter.
From your description, it seems the issue with utun42 not appearing on Windows and inconsistencies between name and friendly_name should now be resolved. Could you please test with the latest version of netdev and confirm if this resolves the problem?
If you encounter further issues or have additional feedback, don’t hesitate to reach out.
It appears to be working. Thanks!