Skip to content

Instantly share code, notes, and snippets.

@appare45
Created December 13, 2023 04:54
Show Gist options
  • Save appare45/be915c9167b3b37b41cc453117fe9854 to your computer and use it in GitHub Desktop.
Save appare45/be915c9167b3b37b41cc453117fe9854 to your computer and use it in GitHub Desktop.
get list of NIC
use nix::ifaddrs;
fn main() {
println!("Hello, world!");
let addrs = nix::ifaddrs::getifaddrs().unwrap();
for ifaddr in addrs {
match ifaddr.address {
Some(address) => {
println!("interface {} address {}", ifaddr.interface_name, address);
}
None => {
println!(
"interface {} with unsupported address family",
ifaddr.interface_name
);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment