| Crates.io | inherface |
| lib.rs | inherface |
| version | 0.2.0 |
| created_at | 2025-06-11 18:31:09.64118+00 |
| updated_at | 2025-06-17 21:48:36.097436+00 |
| description | Retrieve a system's Network Interfaces on Linux |
| homepage | |
| repository | https://codeberg.org/black-cat/inherface |
| max_upload_size | |
| id | 1708950 |
| size | 49,999 |
This project is used to get a linux system's network interfaces.
It is a fork of network-interface, a project by Esteban Borai and others.
We'll talk about why you might choose inherface vs network-interface below.
This project provides both a binary and a library.
Install with cargo install inherface then run inherface. At this moment, there are no CLI arguments to pass.
Add to your project with cargo add inherface.
All features except serde are enabled by default. Adjust as necessary.
Here is an example to get a specific interface by name:
use inherface::get_interfaces;
fn main() {
// interfaces is a HashMap<String, NetworkInterface>
let interfaces = get_interfaces().unwrap();
let ethernet_interface = interfaces.get("eth0").expect("Interface not found");
}
Or iterating through all interfaces:
use inherface::get_interfaces;
fn main() {
let interfaces = get_interfaces().unwrap();
interfaces.values().for_each(|interface| println!("{:?}", interface));
}
Would output something like:
NetworkInterface { name: "eth0", index: 2, v4_addr: [V4IfAddr { ip: 192.168.1.123, broadcast: Some(192.168.1.255), netmask: Some(255.255.255.0) }], v6_addr: [V6IfAddr { ip: <redacted>, broadcast: None, netmask: Some(ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff) }, V6IfAddr { ip: <redacted>, broadcast: None, netmask: Some(ffff:ffff:ffff:ffff::) }, V6IfAddr { ip: <redacted>, broadcast: None, netmask: Some(ffff:ffff:ffff:ffff::) }], mac_addr: Some(MacAddress { bytes: [<redacted>] }) }
NetworkInterface { name: "lo", index: 1, v4_addr: [V4IfAddr { ip: 127.0.0.1, broadcast: Some(127.255.255.255), netmask: Some(255.0.0.0) }], v6_addr: [V6IfAddr { ip: ::1, broadcast: None, netmask: Some(ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff) }], mac_addr: Some(MacAddress { bytes: [0, 0, 0, 0, 0, 0] }) }
NetworkInterface { name: "wlan0", index: 3, v4_addr: [], v6_addr: [], mac_addr: Some(MacAddress { bytes: [<redacted>] }) }
At the time of writing...
Pros of using inherface:
Cons of using inherface (consider using network-interface):
Distributed under the terms of the GNU Library General Public License (Version 2.0). See the LICENSE file for more information.