https://github.com/mozilla/mtu
Rust crate for obtaining the local network interface name and MTU towards a given IP address
https://github.com/mozilla/mtu
interface mozilla mtu
Last synced: 6 months ago
JSON representation
Rust crate for obtaining the local network interface name and MTU towards a given IP address
- Host: GitHub
- URL: https://github.com/mozilla/mtu
- Owner: mozilla
- License: apache-2.0
- Created: 2024-08-30T12:27:11.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-31T05:39:29.000Z (6 months ago)
- Last Synced: 2025-03-31T16:13:56.256Z (6 months ago)
- Topics: interface, mozilla, mtu
- Language: Rust
- Homepage: https://crates.io/crates/mtu
- Size: 247 KB
- Stars: 26
- Watchers: 7
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
[](https://codecov.io/gh/mozilla/mtu)
[](https://isitmaintained.com/project/mozilla/mtu "Average time to resolve an issue")
[](https://isitmaintained.com/project/mozilla/mtu "Percentage of issues still open")
# mtu
A crate to return the name and maximum transmission unit (MTU) of the local network interface
towards a given destination `SocketAddr`, optionally from a given local `SocketAddr`.## Usage
This crate exports a single function `interface_and_mtu` that returns the name and
[maximum transmission unit (MTU)](https://en.wikipedia.org/wiki/Maximum_transmission_unit)
of the outgoing network interface towards a remote destination identified by an `IpAddr`.## Example
```rust
let destination = IpAddr::V4(Ipv4Addr::LOCALHOST);
let (name, mtu): (String, usize) = mtu::interface_and_mtu(destination).unwrap();
println!("MTU towards {destination} is {mtu} on {name}");
```## Supported Platforms
* Linux
* Android
* macOS
* Windows
* FreeBSD
* NetBSD
* OpenBSD
* Solaris## Notes
The returned MTU may exceed the maximum IP packet size of 65,535 bytes on some platforms for
some remote destinations. (For example, loopback destinations on Windows.)The returned interface name is obtained from the operating system.
## Contributing
We're happy to receive PRs that improve this crate. Please take a look at our [community
guidelines](CODE_OF_CONDUCT.md) beforehand.License: MIT OR Apache-2.0