https://github.com/al8n/getifs
A bunch of cross platform network tools for fetching interfaces, multicast addresses, local ip addresses, private ip addresses, public ip addresses and etc.
https://github.com/al8n/getifs
getifaddrs network-interface network-interfaces rust
Last synced: 6 months ago
JSON representation
A bunch of cross platform network tools for fetching interfaces, multicast addresses, local ip addresses, private ip addresses, public ip addresses and etc.
- Host: GitHub
- URL: https://github.com/al8n/getifs
- Owner: al8n
- License: apache-2.0
- Created: 2025-01-01T11:04:04.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-29T00:29:35.000Z (7 months ago)
- Last Synced: 2025-07-30T09:49:54.990Z (7 months ago)
- Topics: getifaddrs, network-interface, network-interfaces, rust
- Language: Rust
- Homepage:
- Size: 88.9 KB
- Stars: 21
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
GetIfs
A bunch of cross-platform network tools for fetching interfaces, multicast addresses, local ip addresses, private ip addresses, public ip addresses and etc.
[
][Github-url]
[
][CI-url]
[
][codecov-url]
[
][doc-url]
[
][crates-url]
[
][crates-url]

## Introduction
A bunch of cross-platform network tools for fetching interfaces, multicast addresses, local ip addresses, private ip addresses, public ip addresses and etc.
## Installation
```toml
[dependencies]
getifs = "0.3"
```
## Examples
- Fetching all interfaces: [examples/interfaces.rs](./examples/interfaces.rs)
- Fetching all interface addresses (excluding multicast addrs): [examples/addrs.rs](./examples/addrs.rs)
- Fetching all interface multicast addresses: [exampels/multicast_addrs.rs](./examples/multicast_addrs.rs)
- Fetching gateway addresses: [examples/gateway.rs](./examples/gateway.rs)
- Fetching local ip addresses: [examples/local_ip_addrs.rs](./examples/local_ip_addrs.rs)
- Fetching ip addresses by RFC: [examples/filter_by_rfc.rs](./examples/filter_by_rfc.rs)
## Details
OS | Approach
--- | ---
Linux (no `libc`) | `socket(AF_NETLINK, SOCK_RAW \| SOCK_CLOEXEC, NETLINK_ROUTE)`
BSD-like | `sysctl`
Windows | `GetAdaptersAddresses`
## Why a new network interfaces crate?
When implementing [`agnostic-mdns`](https://github.com/al8n/agnostic-mdns) (an mDNS crate), I found that Rust was missing a crate to help play with network interfaces and addresses.
All of current network interfaces crates do not support fetching `MTU` and multicast addresses, and almost all of them are using `libc::getifaddrs`. This crate
tries to avoid unneeded allocation and use more underlying method to achieve the same functionalities.
Hence, `getifs` is here, which contain a bunch of cross-platform network tools for fetching interfaces, multicast addresses, local ip addresses, private ip addresses, public ip addresses and etc.
## Roadmap
- [ ] Support fetching routing tables (0.4.0)
## Benchmarks
### Ubuntu 22.04 ARM64 (Parallel Desktop, 1 CPU, 8GB memory)

### MacOS (Apple M1 Max, 32GB)

## Sister crates
- [`iprobe`](https://github.com/al8n/iprobe): Probe if the host system supports IPv4, IPv6 and IPv4-mapped-IPv6.
- [`iprfc`](https://github.com/al8n/iprfc): Known RFCs for IP addresses.
## Pedigree
- The code in this crate is inspired by Golang's `interface.go` and [HashiCorp's go-sockaddr](https://github.com/hashicorp/go-sockaddr).
#### License
`getifs` is under the terms of both the MIT license and the
Apache License (Version 2.0).
See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT) for details.
Copyright (c) 2025 Al Liu.
[Github-url]: https://github.com/al8n/getifs/
[CI-url]: https://github.com/al8n/getifs/actions/workflows/ci.yml
[doc-url]: https://docs.rs/getifs
[crates-url]: https://crates.io/crates/getifs
[codecov-url]: https://app.codecov.io/gh/al8n/getifs/