ifaddr


Nameifaddr JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/pydron/ifaddr
SummaryCross-platform network interface and IP address enumeration library
upload_time2022-06-15 21:40:27
maintainer
docs_urlhttps://pythonhosted.org/ifaddr/
authorStefan C. Mueller
requires_python
licenseMIT
keywords network interfaces network adapters network addresses ip addresses
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ifaddr - Enumerate network interfaces/adapters and their IP addresses
=====================================================================

.. image:: https://github.com/pydron/ifaddr/workflows/CI/badge.svg
    :target: https://github.com/pydron/ifaddr/actions?query=workflow%3ACI+branch%3Amaster

.. image:: https://img.shields.io/pypi/v/ifaddr.svg
    :target: https://pypi.python.org/pypi/ifaddr

.. image:: https://codecov.io/gh/pydron/ifaddr/branch/master/graph/badge.svg
  :target: https://codecov.io/gh/pydron/ifaddr

`ifaddr` is a small Python library that allows you to find all the Ethernet and
IP addresses of the computer. It is tested on **Linux**, **OS X**, and
**Windows**. Other BSD derivatives like **OpenBSD**, **FreeBSD**, and
**NetBSD** should work too, but I haven't personally tested those.
**Solaris/Illumos** should also work.

This library is open source and released under the MIT License. It works
with Python 3.7+.

You can install it with `pip install ifaddr`. It doesn't need to
compile anything, so there shouldn't be any surprises. Even on Windows.

Project links:

* `ifaddr GitHub page <https://github.com/smurn/ifaddr>`_
* `ifaddr documentation (although there isn't much to document) <http://pythonhosted.org/ifaddr/>`_
* `ifaddr on PyPI <https://pypi.org/project/ifaddr/>`_


----------------------
Let's get going!
----------------------

.. code-block:: python

    import ifaddr

    adapters = ifaddr.get_adapters()

    for adapter in adapters:
        print("IPs of network adapter " + adapter.nice_name)
        for ip in adapter.ips:
            print("   %s/%s" % (ip.ip, ip.network_prefix))

This will print::

    IPs of network adapter H5321 gw Mobile Broadband Driver
       IP ('fe80::9:ebdf:30ab:39a3', 0L, 17L)/64
       IP 169.254.57.163/16
    IPs of network adapter Intel(R) Centrino(R) Advanced-N 6205
       IP ('fe80::481f:3c9d:c3f6:93f8', 0L, 12L)/64
       IP 192.168.0.51/24
    IPs of network adapter Intel(R) 82579LM Gigabit Network Connection
       IP ('fe80::85cd:e07e:4f7a:6aa6', 0L, 11L)/64
       IP 192.168.0.53/24
    IPs of network adapter Software Loopback Interface 1
       IP ('::1', 0L, 0L)/128
       IP 127.0.0.1/8

You get both IPv4 and IPv6 addresses. The later complete with
flowinfo and scope_id.

If you wish to include network interfaces that do not have a configured IP
addresss, pass the `include_unconfigured` parameter to `get_adapters()`.
Adapters with no configured IP addresses will have an zero-length `ips`
property.  For example:

.. code-block:: python

    import ifaddr

    adapters = ifaddr.get_adapters(include_unconfigured=True)

    for adapter in adapters:
        print("IPs of network adapter " + adapter.nice_name)
        if adapter.ips:
            for ip in adapter.ips:
                print("   %s/%s" % (ip.ip, ip.network_prefix))
        else:
            print("  No IPs configured")


---------
Changelog
---------

0.2.0
-----

* Added an option to include IP-less adapters, thanks to memory
* Fixed a bug where an interface's name was `bytes`, not `str`, on Windows
* Added an implementation of `netifaces.interfaces()` (available through
  `ifaddr.netifaces.interfaces()`)
* Added type hints

Backwards incompatible/breaking changes:

* Dropped Python 3.6 support

0.1.7
-----

* Fixed Python 3 compatibility in the examples, thanks to Tristan Stenner and Josef Schlehofer
* Exposed network interface indexes in Adapter.index, thanks to Dmitry Tantsur
* Added the license file to distributions on PyPI, thanks to Tomáš Chvátal
* Fixed Illumos/Solaris compatibility based on a patch proposed by Jorge Schrauwen
* Set up universal wheels, ifaddr will have both source and wheel distributions on PyPI from now on

------------
Alternatives
------------

Alastair Houghton develops `netifaces  <https://pypi.python.org/pypi/netifaces>`_
which can do  everything this library can, and more. The only drawback is that it needs
to be compiled, which can make the installation difficult.

As of ifaddr 0.2.0 we implement the equivalent of `netifaces.interfaces()`. It's available through
`ifaddr.netifaces.interfaces()`.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pydron/ifaddr",
    "name": "ifaddr",
    "maintainer": "",
    "docs_url": "https://pythonhosted.org/ifaddr/",
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "network interfaces,network adapters,network addresses,IP addresses",
    "author": "Stefan C. Mueller",
    "author_email": "scm@smurn.org",
    "download_url": "https://files.pythonhosted.org/packages/e8/ac/fb4c578f4a3256561548cd825646680edcadb9440f3f68add95ade1eb791/ifaddr-0.2.0.tar.gz",
    "platform": null,
    "description": "ifaddr - Enumerate network interfaces/adapters and their IP addresses\n=====================================================================\n\n.. image:: https://github.com/pydron/ifaddr/workflows/CI/badge.svg\n    :target: https://github.com/pydron/ifaddr/actions?query=workflow%3ACI+branch%3Amaster\n\n.. image:: https://img.shields.io/pypi/v/ifaddr.svg\n    :target: https://pypi.python.org/pypi/ifaddr\n\n.. image:: https://codecov.io/gh/pydron/ifaddr/branch/master/graph/badge.svg\n  :target: https://codecov.io/gh/pydron/ifaddr\n\n`ifaddr` is a small Python library that allows you to find all the Ethernet and\nIP addresses of the computer. It is tested on **Linux**, **OS X**, and\n**Windows**. Other BSD derivatives like **OpenBSD**, **FreeBSD**, and\n**NetBSD** should work too, but I haven't personally tested those.\n**Solaris/Illumos** should also work.\n\nThis library is open source and released under the MIT License. It works\nwith Python 3.7+.\n\nYou can install it with `pip install ifaddr`. It doesn't need to\ncompile anything, so there shouldn't be any surprises. Even on Windows.\n\nProject links:\n\n* `ifaddr GitHub page <https://github.com/smurn/ifaddr>`_\n* `ifaddr documentation (although there isn't much to document) <http://pythonhosted.org/ifaddr/>`_\n* `ifaddr on PyPI <https://pypi.org/project/ifaddr/>`_\n\n\n----------------------\nLet's get going!\n----------------------\n\n.. code-block:: python\n\n    import ifaddr\n\n    adapters = ifaddr.get_adapters()\n\n    for adapter in adapters:\n        print(\"IPs of network adapter \" + adapter.nice_name)\n        for ip in adapter.ips:\n            print(\"   %s/%s\" % (ip.ip, ip.network_prefix))\n\nThis will print::\n\n    IPs of network adapter H5321 gw Mobile Broadband Driver\n       IP ('fe80::9:ebdf:30ab:39a3', 0L, 17L)/64\n       IP 169.254.57.163/16\n    IPs of network adapter Intel(R) Centrino(R) Advanced-N 6205\n       IP ('fe80::481f:3c9d:c3f6:93f8', 0L, 12L)/64\n       IP 192.168.0.51/24\n    IPs of network adapter Intel(R) 82579LM Gigabit Network Connection\n       IP ('fe80::85cd:e07e:4f7a:6aa6', 0L, 11L)/64\n       IP 192.168.0.53/24\n    IPs of network adapter Software Loopback Interface 1\n       IP ('::1', 0L, 0L)/128\n       IP 127.0.0.1/8\n\nYou get both IPv4 and IPv6 addresses. The later complete with\nflowinfo and scope_id.\n\nIf you wish to include network interfaces that do not have a configured IP\naddresss, pass the `include_unconfigured` parameter to `get_adapters()`.\nAdapters with no configured IP addresses will have an zero-length `ips`\nproperty.  For example:\n\n.. code-block:: python\n\n    import ifaddr\n\n    adapters = ifaddr.get_adapters(include_unconfigured=True)\n\n    for adapter in adapters:\n        print(\"IPs of network adapter \" + adapter.nice_name)\n        if adapter.ips:\n            for ip in adapter.ips:\n                print(\"   %s/%s\" % (ip.ip, ip.network_prefix))\n        else:\n            print(\"  No IPs configured\")\n\n\n---------\nChangelog\n---------\n\n0.2.0\n-----\n\n* Added an option to include IP-less adapters, thanks to memory\n* Fixed a bug where an interface's name was `bytes`, not `str`, on Windows\n* Added an implementation of `netifaces.interfaces()` (available through\n  `ifaddr.netifaces.interfaces()`)\n* Added type hints\n\nBackwards incompatible/breaking changes:\n\n* Dropped Python 3.6 support\n\n0.1.7\n-----\n\n* Fixed Python 3 compatibility in the examples, thanks to Tristan Stenner and Josef Schlehofer\n* Exposed network interface indexes in Adapter.index, thanks to Dmitry Tantsur\n* Added the license file to distributions on PyPI, thanks to Tom\u00e1\u0161 Chv\u00e1tal\n* Fixed Illumos/Solaris compatibility based on a patch proposed by Jorge Schrauwen\n* Set up universal wheels, ifaddr will have both source and wheel distributions on PyPI from now on\n\n------------\nAlternatives\n------------\n\nAlastair Houghton develops `netifaces  <https://pypi.python.org/pypi/netifaces>`_\nwhich can do  everything this library can, and more. The only drawback is that it needs\nto be compiled, which can make the installation difficult.\n\nAs of ifaddr 0.2.0 we implement the equivalent of `netifaces.interfaces()`. It's available through\n`ifaddr.netifaces.interfaces()`.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Cross-platform network interface and IP address enumeration library",
    "version": "0.2.0",
    "split_keywords": [
        "network interfaces",
        "network adapters",
        "network addresses",
        "ip addresses"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9c1f19ebc343cc71a7ffa78f17018535adc5cbdd87afb31d7c34874680148b32",
                "md5": "95a2475cabf59fce4e38a5ef334fa985",
                "sha256": "085e0305cfe6f16ab12d72e2024030f5d52674afad6911bb1eee207177b8a748"
            },
            "downloads": -1,
            "filename": "ifaddr-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "95a2475cabf59fce4e38a5ef334fa985",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 12314,
            "upload_time": "2022-06-15T21:40:25",
            "upload_time_iso_8601": "2022-06-15T21:40:25.756202Z",
            "url": "https://files.pythonhosted.org/packages/9c/1f/19ebc343cc71a7ffa78f17018535adc5cbdd87afb31d7c34874680148b32/ifaddr-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e8acfb4c578f4a3256561548cd825646680edcadb9440f3f68add95ade1eb791",
                "md5": "b1cac02b5dc354d68dd6d853bc9565a7",
                "sha256": "cc0cbfcaabf765d44595825fb96a99bb12c79716b73b44330ea38ee2b0c4aed4"
            },
            "downloads": -1,
            "filename": "ifaddr-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b1cac02b5dc354d68dd6d853bc9565a7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10485,
            "upload_time": "2022-06-15T21:40:27",
            "upload_time_iso_8601": "2022-06-15T21:40:27.561828Z",
            "url": "https://files.pythonhosted.org/packages/e8/ac/fb4c578f4a3256561548cd825646680edcadb9440f3f68add95ade1eb791/ifaddr-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-06-15 21:40:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "pydron",
    "github_project": "ifaddr",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ifaddr"
}
        
Elapsed time: 0.09481s