Cross-platform library for network interface. Written in Rust.
[crates-badge]: https://img.shields.io/crates/v/netdev.svg [crates-url]: https://crates.io/crates/netdev [license-badge]: https://img.shields.io/crates/l/netdev.svg [examples-url]: https://github.com/shellrow/netdev/tree/main/examples [doc-url]: https://docs.rs/netdev/latest/netdev [doc-interface-url]: https://docs.rs/netdev/latest/netdev/interface/interface/struct.Interface.html [netdev-github-url]: https://github.com/shellrow/netdev [default-net-github-url]: https://github.com/shellrow/default-net [default-net-crates-io-url]: https://crates.io/crates/default-net
netdev [![Crates.io][crates-badge]][crates-url] ![License][license-badge]
Cross-platform library for enumerating network interfaces with metadata. netdev provides a unified API for discovering local network interfaces and retrieving commonly used metadata across platforms.
Key Features
- Enumerate all available network interfaces
- Detect the default network interface
- Retrieve interface metadata:
- Native traffic statistics (RX/TX bytes) for each interface
- Designed for cross-platform
Supported platforms
- Linux
- macOS
- Windows
- Android
- iOS
- BSDs
Usage
Addnetdev to your Cargo.toml:
[dependencies]
netdev = "0.45"
For more details, see [examples][examples-url] or [doc][doc-url].
Feature flags
gateway(default)
apple-system-configuration-extra(default)
SystemConfiguration APIs.
- On Apple targets, this adds metadata such as interface display names, DHCP hints, and iOS DNS resolver lookup when the platform exposes them.
android-extra(default)
To opt out of the additional Apple metadata enrichment while keeping gateway helpers:
[dependencies]
netdev = { version = "0.45", default-features = false, features = ["gateway"] }
Apple behavior
netdev links SystemConfiguration.framework automatically on macOS and iOS through its build script.
If your app is ultimately linked by Xcode, you may still need to add SystemConfiguration.framework to the app target manually.
Android behavior
If you want Android-specific values such as DNS servers, DHCP hints, or Wi-Fi link speed, your app may still need to initialize the Android context for Rust and declare Android permissions such asACCESSNETWORKSTATE and ACCESSWIFISTATE.
Project History
This crate was originally published as [default-net][default-net-crates-io-url] and was later rebranded tonetdev by the author for future expansion, clearer naming, and long-term maintenance.
Tested on
- Linux
- macOS (Apple Silicon)
- macOS (Intel)
- Windows
- FreeBSD
- Android (arm64)
- Android (x86_64)
- iOS