Closed xmh0511 closed 8 months ago
You might first want to determine the ifindex since the library doesn't currently support specifying interfaces by name #7, for example with this function: https://www.man7.org/linux/man-pages/man3/if_nametoindex.3.html
let tun_ifindex: u32 = 3;
let handle = Handle::new()?;
let route = Route::new("0.0.0.0".parse().unwrap(), 0).with_ifindex(tun_ifindex);
handle.add(&route).await
You might first want to determine the ifindex since the library doesn't currently support specifying interfaces by name #7, for example with this function: https://www.man7.org/linux/man-pages/man3/if_nametoindex.3.html
let tun_ifindex: u32 = 3; let handle = Handle::new()?; let route = Route::new("0.0.0.0".parse().unwrap(), 0).with_ifindex(tun_ifindex); handle.add(&route).await
Thanks. ~But, what should I do on the Windows platform? IMO, Windows does not have an interface index.~
Does with_ifindex
still work on the Windows platform when geting if_index with https://microsoft.github.io/windows-docs-rs/doc/windows/Win32/NetworkManagement/IpHelper/fn.if_nametoindex.html
@johnyburd handle.add(&route).await
just return the error:
Err(Custom { kind: AlreadyExists, error: "rtm_errno 17" })
index.crates.io-6f17d22bba15001f/net-route-0.2.11/src/platform_impl/macos/macos.rs:254:25:
index out of bounds: the len is 12 but the index is 12
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
yes Route::with_ifindex
is supported on windows.
I'm not able to tell what's wrong in the snipped you posted from macos. I would need a minimum reproduction of the error and perhaps a dump of your routing table.
yes
Route::with_ifindex
is supported on windows.I'm not able to tell what's wrong in the snipped you posted from macos. I would need a minimum reproduction of the error and perhaps a dump of your routing table.
It's here https://github.com/johnyburd/net-route/issues/15#issuecomment-1890300339
Closing in favor of #7
How do I achieve this target by using this crate? Honestly, the documentation is lack, I don't know how to do.