default-net Crates.io License

Get default network information
default-net provides a cross-platform API for network interface and gateway.

Supported platform

Usage

Add default-net to your dependencies
toml:Cargo.toml [dependencies] default-net = "0.5.0"

Example

```rust use default_net;

fn main(){ match defaultnet::getdefaultinterface() { Ok(defaultinterface) => { println!("Default Interface"); println!("\tIndex: {}", defaultinterface.index); println!("\tName: {}", defaultinterface.name); if let Some(macaddr) = defaultinterface.macaddr { println!("\tMAC: {}", macaddr); }else{ println!("\tMAC: (Failed to get mac address)"); } println!("\tIPv4: {:?}", defaultinterface.ipv4); println!("\tIPv6: {:?}", defaultinterface.ipv6); if let Some(gateway) = defaultinterface.gateway { println!("Default Gateway"); println!("\tMAC: {}", gateway.macaddr); println!("\tIP: {}", gateway.ip_addr); }else { println!("Default Gateway: (Not found)"); } }, Err(e) => { println!("{}", e); }, } } ```

Tested on

For more details, see examples or doc.