If you want to do any of these types of operations from Rust, you can use https://docs.rs/netdiag/latest/netdiag/. It's very good.