Skip to main content

This is a Python module for manipulating subnet information. It adds useful utilities to the built-in Python ipaddress library. It requires Python 3+ and supports both IPv4 and IPv6 subnets.

Example usage

Create a subnet object:

from subnet import ip_network, IPv4Network, IPv6Network

# The simple way takes either IPv4 or IPv6 CIDR notation
my_subnet = ip_network('10.10.0.0/16')

# The specific type way
my_ipv4_subnet = IPv4Network('10.10.0.0/16')
my_ipv6_subnet = IPv6Network('fd3e:48fe:59b2:43ca::/64')

Divide a subnet into useful chunks (as evenly as plausible):

for subnet in my_ipv4_subnet.divide(6):
    print(subnet)

for subnet in my_ipv6_subnet.divide(2):
    print(subnet)

Get a random ip from a subnet:

print(my_subnet.random_ip())

Command line usage

It is also possible to perform various tasks from the command line directly:

$ network-divide 10.0.0.0/8 4
$ network-random-ip fd3e:48fe:59b2:43ca::/64
$ network-info 192.168.0.0/24

Metadata

Release files for subnet-utils 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for subnet-utils 0.5.2
File Size Uploaded Provenance
subnet_utils-0.5.2.tar.gz 4.8 kB Without provenance Details

Release files / subnet_utils-0.5.2.tar.gz

Download URL subnet_utils-0.5.2.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cefa7d125a42019151461bd65576164e386825e0c7ea1d9db471f6b9d7a05c72
BLAKE2b-256 checksum
How to use checksums
58c64ef2466a7e8433be288f3bc55b2ef5f3ae7780d4f21e5c69149679d3257a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.6

Security for subnet-utils 0.5.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page