{"id":5968,"library":"ipaddr","title":"Google's IP Address Manipulation Library","description":"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.","status":"deprecated","version":"2.2.0","language":"en","source_language":"en","source_url":"https://github.com/google/ipaddr-py","tags":["networking","IP addresses","IPv4","IPv6","deprecated"],"install":[{"cmd":"pip install ipaddr","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"IPAddress is a class, import directly or use ipaddr.IPAddress() after importing the module.","wrong":"import ipaddr.IPAddress","symbol":"IPAddress","correct":"from ipaddr import IPAddress"},{"note":"IPNetwork is a class, import directly or use ipaddr.IPNetwork() after importing the module.","wrong":"import ipaddr.IPNetwork","symbol":"IPNetwork","correct":"from ipaddr import IPNetwork"}],"quickstart":{"code":"import ipaddr\n\n# Create an IPv4 address object\nip_v4 = ipaddr.IPAddress('192.168.1.1')\nprint(f\"IPv4 Address: {ip_v4}\")\nprint(f\"Is private: {ip_v4.is_private}\")\n\n# Create an IPv6 address object\nip_v6 = ipaddr.IPAddress('2001:db8::1')\nprint(f\"IPv6 Address: {ip_v6}\")\n\n# Create a network object\nnetwork = ipaddr.IPNetwork('192.168.1.0/24')\nprint(f\"Network: {network}\")\nprint(f\"Network address: {network.network}\")\nprint(f\"Broadcast address: {network.broadcast}\")\nprint(f\"Number of hosts: {network.numhosts}\")\n\n# Check if an address is in a network\nprint(f\"192.168.1.5 in network: {ipaddr.IPAddress('192.168.1.5') in network}\")\n","lang":"python","description":"This quickstart demonstrates how to create IP address and network objects using the `ipaddr` library, check their properties, and perform basic network membership tests."},"warnings":[{"fix":"Migrate your codebase from `ipaddr` to the built-in `ipaddress` module. The API is largely similar but has some differences (e.g., stricter network object creation, renamed factory functions). Refer to PEP 3144 for a detailed comparison of API changes: https://peps.python.org/pep-3144/","message":"The `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.","severity":"breaking","affected_versions":"All versions (migration recommended for Python 3 users)"},{"fix":"Always ensure the host portion of a network address is zero when defining a network, e.g., '192.168.1.0/24'. If migrating to `ipaddress`, be aware that `ipaddress`'s `*Network` classes default to `strict=True`, requiring canonical network addresses. For interface objects (address on a network), use `ipaddr.IPNetwork('192.168.1.5/24', strict=False)` or `ipaddress.ip_interface('192.168.1.5/24')` in `ipaddress`.","message":"When 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.","severity":"gotcha","affected_versions":"All `ipaddr` versions, compared to `ipaddress` module"},{"fix":"When migrating to the `ipaddress` module, use `ipaddress.ip_address()` for addresses and `ipaddress.ip_network()` for networks. These factory functions automatically determine the IP version (IPv4 or IPv6) and return the appropriate object.","message":"The `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.","severity":"deprecated","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}