{"id":2066,"library":"ifaddr","title":"ifaddr Library","description":"ifaddr is a small, cross-platform Python library designed for enumerating network interfaces and their associated IP addresses. It supports Linux, OS X, Windows, and is expected to work on other BSD derivatives and Solaris/Illumos. Released under the MIT License, the current version 0.2.0 (June 2022) works with Python 3.9+ and requires no compilation, simplifying installation.","status":"active","version":"0.2.0","language":"en","source_language":"en","source_url":"https://github.com/pydron/ifaddr","tags":["network","IP","address","interface","cross-platform","enumeration"],"install":[{"cmd":"pip install ifaddr","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Runtime environment. Requires Python 3.9+ as of version 0.2.0.","package":"python","optional":false}],"imports":[{"symbol":"get_adapters","correct":"import ifaddr\nadapters = ifaddr.get_adapters()"}],"quickstart":{"code":"import ifaddr\n\n# Get all network adapters\nadapters = ifaddr.get_adapters()\n\nfor adapter in adapters:\n    print(f\"IPs of network adapter {adapter.nice_name}\")\n    if adapter.ips:\n        for ip in adapter.ips:\n            # ip.ip will be a string for IPv4, and a tuple (ip_str, flowinfo, scope_id) for IPv6\n            print(f\"  {ip.ip}/{ip.network_prefix}\")\n    else:\n        print(\"  No IPs configured\")\n\n# To include interfaces without configured IP addresses:\n# adapters_with_unconfigured = ifaddr.get_adapters(include_unconfigured=True)\n","lang":"python","description":"This example demonstrates how to retrieve all network adapters and iterate through their configured IP addresses. It also shows how to include unconfigured adapters if needed."},"warnings":[{"fix":"Upgrade to Python 3.7+ (preferably 3.9+ as per the latest README) if using ifaddr 0.2.0 or newer.","message":"Version 0.2.0 dropped support for Python 3.6.","severity":"breaking","affected_versions":"0.2.0 and later"},{"fix":"Use `ifaddr.get_adapters(include_unconfigured=True)` to retrieve all interfaces, regardless of IP configuration.","message":"By default, `ifaddr.get_adapters()` only returns interfaces with configured IP addresses. To include interfaces without any assigned IP, pass `include_unconfigured=True`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be aware that `ip.ip` for IPv6 addresses is a tuple. Access the string representation as `ip.ip[0]` if only the address string is needed.","message":"For IPv6 addresses, the `ip.ip` attribute returns a three-tuple: `(ip_address_string, flowinfo, scope_id)`, not just a string, which might require unpacking or specific handling.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Prefer `adapter.nice_name` for displaying adapter names to users, especially on Windows.","message":"On Windows, the `adapter.name` property returns a UUID string, not a human-readable name. Use `adapter.nice_name` for a more descriptive identifier.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consider `netifaces` if more in-depth interface details (e.g., multicast addresses, status flags) are required, acknowledging its compilation dependency. For a subset of `netifaces` functionality, explore `ifaddr.netifaces` module.","message":"While `ifaddr` is lightweight and doesn't require compilation, the `netifaces` library offers more comprehensive network interface information. As of `ifaddr` 0.2.0, an equivalent to `netifaces.interfaces()` is available at `ifaddr.netifaces.interfaces()`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}