A Rust library for retrieving network interface information, including names and IP addresses of all active network interfaces. This crate provides a cross-platform solution that works on Windows, Linux, macOS, and other Unix-like systems.
- Get network interface names
- Retrieve IPv4 and IPv6 addresses for each interface
- Cross-platform support (Windows, Linux, macOS, and other Unix-like systems)
- Easy-to-use API
- No unsafe code (except for necessary FFI bindings)
Add this to your Cargo.toml
:
[dependencies]
ifaddrsx = "0.3"
use ifaddrsx::get_ifaddrs;
fn main() {
let ifaddrs = get_ifaddrs().unwrap();
for ifaddr in ifaddrs {
println!("Interface: {}", ifaddr.name);
println!(" IP Addresses: {:?}", ifaddr.ips);
}
}
- Windows (via WinAPI)
- Linux (via netlink)
- macOS and other Unix-like systems (via getifaddrs)
bitflags
: For flag handlingipnetwork
: IP address manipulationlibc
: System library bindings- Platform-specific dependencies:
- Windows:
winapi
with network-related features - Unix:
nix
for network operations
- Windows:
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
Sprite Tong spritetong@gmail.com