$ ipnet
v2.12.0MAJOR UPDATEProvides types and useful methods for working with IPv4 and IPv6 network addresses, commonly called IP prefixes. The new `IpNet`, `Ipv4Net`, and `Ipv6Net` types build on the existing `IpAddr`, `Ipv4Addr`, and `Ipv6Addr` types already provided in Rust's standard library and align to their design to stay consistent. The module also provides useful traits that extend `Ipv4Addr` and `Ipv6Addr` with methods for `Add`, `Sub`, `BitAnd`, and `BitOr` operations. The module only uses stable feature so it is guaranteed to compile using the stable toolchain.
Latest Update Summary
Crate
Name: ipnet New version: 2.12.0 Release date: 2026-03-03T00:44:44.752166Z
Crate readme
Short description This module provides types and useful methods for working with IPv4 and IPv6 network addresses, commonly called IP prefixes.
Long description
The module includes IpNet, Ipv4Net, and Ipv6Net types built on IpAddr, Ipv4Addr, and Ipv6Addr. It also offers types for iterating over IP address ranges (IpAddrRange, Ipv4AddrRange, Ipv6AddrRange) and methods extending Ipv4Addr and Ipv6Addr for arithmetic operations. It is compatible with Rust stable features, requires Rust 1.26 or later, and contains comprehensive tests.
Features
• Stable Rust features guaranteed to compile with stable toolchain
• Requires Rust 1.26 or later
• Types for iterating IP subnets and address ranges
• subnets() method for subdividing networks
• Extends native IP address types with useful methods
Code Examples Create a network address and print the hostmask and netmask
let net4 = Ipv4Net::new(Ipv4Addr::new(10, 1, 1, 0), 24).unwrap();
let net6 = Ipv6Net::new(Ipv6Addr::new(0xfd, 0, 0, 0, 0, 0, 0, 0), 24).unwrap();
Subdivide an existing IP network into smaller subnets
let net: Ipv4Net = "192.168.0.0/23".parse().unwrap();
let subnets = net.subnets(25).expect("PrefixLenError: new prefix length cannot be shorter than existing");
Iterate over the valid subnets between two IPv4 addresses
let start = Ipv4Addr::new(10, 0, 0, 0);
let end = Ipv4Addr::new(10, 0, 0, 239);
let subnets = Ipv4Subnets::new(start, end, 0);
Aggregate a list of IP prefixes
let strings = vec!["10.0.0.0/24", "10.0.1.0/24"];
let nets: Vec<IpNet> = strings.iter().filter_map(|p| p.parse().ok()).collect();
Links • https://docs.rs/ipnet/ • https://crates.io/crates/ipnet • https://github.com/krisprice/ipnet/issues
https://docs.rs/ipnet https://api.github.com/repos/krisprice/ipnet/releases/292324056
Release info
Release version:
Release description
Code Examples
Minor update: 2.11.0 → 2.12.0
$ DOWNLOADS TREND
$ VERSION HISTORY
$ LINKS
$ INSTALL
cargo add ipnetOr add to Cargo.toml: ipnet = "2.12.0"