net-route 0.4.6

This crate provides a cross-platform interface for manipulating the routing table
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use net_route::{Handle, Route};

#[tokio::main]
async fn main() -> std::io::Result<()> {
    let handle = Handle::new()?;
    let route = Route::new("192.168.2.0".parse().unwrap(), 26)
        // windows options
        //.with_luid(19985273102270464)
        //.with_metric(5)
        //.with_ifindex(6)
        .with_gateway("192.168.2.1".parse().unwrap());
    println!("route add {:?}", route);
    handle.add(&route).await
}