Registry / serialization / ipaddr

ipaddr

JSON →
library2.2.0pypypi✓ verified 35d ago

ipaddr (pypi-slug: ipaddr) is a Python library developed by Google for manipulating IPv4 and IPv6 addresses and networks. It provides functionalities for validation, subnet operations, and summarization. The last release was version 2.2.0 in 2017. This library has been superseded by the `ipaddress` module, which is part of the Python 3 standard library.

serializationhttp-networking
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

IPAddress is a class, import directly or use ipaddr.IPAddress() after importing the module.

from ipaddr import IPAddress

IPNetwork is a class, import directly or use ipaddr.IPNetwork() after importing the module.

from ipaddr import IPNetwork

This quickstart demonstrates how to create IP address and network objects using the `ipaddr` library, check their properties, and perform basic network membership tests.

import ipaddr # Create an IPv4 address object ip_v4 = ipaddr.IPAddress('192.168.1.1') print(f"IPv4 Address: {ip_v4}") print(f"Is private: {ip_v4.is_private}") # Create an IPv6 address object ip_v6 = ipaddr.IPAddress('2001:db8::1') print(f"IPv6 Address: {ip_v6}") # Create a network object network = ipaddr.IPNetwork('192.168.1.0/24') print(f"Network: {network}") print(f"Network address: {network.network}") print(f"Broadcast address: {network.broadcast}") print(f"Number of hosts: {network.numhosts}") # Check if an address is in a network print(f"192.168.1.5 in network: {ipaddr.IPAddress('192.168.1.5') in network}")
Debug
Known footguns
breakingThe `ipaddr` library has been officially superseded by the `ipaddress` module, which is included in the Python 3 standard library. The PyPI package for `ipaddr` is primarily a backport for Python 2. Users on Python 3 should migrate to `ipaddress` for future compatibility and maintenance.
gotchaWhen creating `IPNetwork` objects with `ipaddr`, the library is more lenient about host bits being set compared to the `ipaddress` module. In `ipaddress`, creating a network object like `ipaddress.ip_network('192.168.1.5/24')` would raise a `ValueError` because the host bits are set. `ipaddr` might implicitly correct this or allow it depending on the version and specific method.
deprecatedThe `ipaddr.IPAddress()` and `ipaddr.IPNetwork()` factory functions had equivalent, but slightly different, behavior and naming conventions compared to the `ipaddress.ip_address()` and `ipaddress.ip_network()` factory functions in the standard library.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources