{ "info": { "author": "GNS3", "author_email": "developers@gns3.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: System :: Networking" ], "description": "WARNING\n========\n\nThis a fork distributed on PyPi until this issue on upstream is solved:\nhttps://bitbucket.org/al45tair/netifaces/issue/13/0104-install-is-broken-on-python-3x\n\nThe original module is here:\nhttps://bitbucket.org/al45tair/netifaces\n\n\nnetifaces 0.10.4\n================\n\n.. image:: https://drone.io/bitbucket.org/al45tair/netifaces/status.png\n :target: https://drone.io/bitbucket.org/al45tair/netifaces/latest\n :alt: Build Status\n\n1. What is this?\n----------------\n\nIt's been annoying me for some time that there's no easy way to get the\naddress(es) of the machine's network interfaces from Python. There is\na good reason for this difficulty, which is that it is virtually impossible\nto do so in a portable manner. However, it seems to me that there should\nbe a package you can easy_install that will take care of working out the\ndetails of doing so on the machine you're using, then you can get on with\nwriting Python code without concerning yourself with the nitty gritty of\nsystem-dependent low-level networking APIs.\n\nThis package attempts to solve that problem.\n\n2. How do I use it?\n-------------------\n\nFirst you need to install it, which you can do by typing::\n\n tar xvzf netifaces-0.10.4.tar.gz\n cd netifaces-0.10.4\n python setup.py install\n\nOnce that's done, you'll need to start Python and do something like the\nfollowing::\n\n>>> import netifaces\n\nThen if you enter\n\n>>> netifaces.interfaces()\n['lo0', 'gif0', 'stf0', 'en0', 'en1', 'fw0']\n\nyou'll see the list of interface identifiers for your machine.\n\nYou can ask for the addresses of a particular interface by doing\n\n>>> netifaces.ifaddresses('lo0')\n{18: [{'addr': ''}], 2: [{'peer': '127.0.0.1', 'netmask': '255.0.0.0', 'addr': '127.0.0.1'}], 30: [{'peer': '::1', 'netmask': 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', 'addr': '::1'}, {'peer': '', 'netmask': 'ffff:ffff:ffff:ffff::', 'addr': 'fe80::1%lo0'}]}\n\nHmmmm. That result looks a bit cryptic; let's break it apart and explain\nwhat each piece means. It returned a dictionary, so let's look there first::\n\n { 18: [...], 2: [...], 30: [...] }\n\nEach of the numbers refers to a particular address family. In this case, we\nhave three address families listed; on my system, 18 is ``AF_LINK`` (which means\nthe link layer interface, e.g. Ethernet), 2 is ``AF_INET`` (normal Internet\naddresses), and 30 is ``AF_INET6`` (IPv6).\n\nBut wait! Don't use these numbers in your code. The numeric values here are\nsystem dependent; fortunately, I thought of that when writing netifaces, so\nthe module declares a range of values that you might need. e.g.\n\n>>> netifaces.AF_LINK\n18\n\nAgain, on your system, the number may be different.\n\nSo, what we've established is that the dictionary that's returned has one\nentry for each address family for which this interface has an address. Let's\ntake a look at the ``AF_INET`` addresses now:\n\n>>> addrs = netifaces.ifaddresses('lo0')\n>>> addrs[netifaces.AF_INET]\n[{'peer': '127.0.0.1', 'netmask': '255.0.0.0', 'addr': '127.0.0.1'}]\n\nYou might be wondering why this value is a list. The reason is that it's\npossible for an interface to have more than one address, even within the\nsame family. I'll say that again: *you can have more than one address of\nthe same type associated with each interface*.\n\n*Asking for \"the\" address of a particular interface doesn't make sense.*\n\nRight, so, we can see that this particular interface only has one address,\nand, because it's a loopback interface, it's point-to-point and therefore\nhas a *peer* address rather than a broadcast address.\n\nLet's look at a more interesting interface.\n\n>>> addrs = netifaces.ifaddresses('en0')\n>>> addrs[netifaces.AF_INET]\n[{'broadcast': '10.15.255.255', 'netmask': '255.240.0.0', 'addr': '10.0.1.4'}, {'broadcast': '192.168.0.255', 'addr': '192.168.0.47'}]\n\nThis interface has two addresses (see, I told you...) Both of them are\nregular IPv4 addresses, although in one case the netmask has been changed\nfrom its default. The netmask *may not* appear on your system if it's set\nto the default for the address range.\n\nBecause this interface isn't point-to-point, it also has broadcast addresses.\n\nNow, say we want, instead of the IP addresses, to get the MAC address; that\nis, the hardware address of the Ethernet adapter running this interface. We\ncan do\n\n>>> addrs[netifaces.AF_LINK]\n[{'addr': '00:12:34:56:78:9a'}]\n\nNote that this may not be available on platforms without getifaddrs(), unless\nthey happen to implement ``SIOCGIFHWADDR``. Note also that you just get the\naddress; it's unlikely that you'll see anything else with an ``AF_LINK`` address.\nOh, and don't assume that all ``AF_LINK`` addresses are Ethernet; you might, for\ninstance, be on a Mac, in which case:\n\n>>> addrs = netifaces.ifaddresses('fw0')\n>>> addrs[netifaces.AF_LINK]\n[{'addr': '00:12:34:56:78:9a:bc:de'}]\n\nNo, that isn't an exceptionally long Ethernet MAC address---it's a FireWire\naddress.\n\nAs of version 0.10.0, you can also obtain a list of gateways on your\nmachine:\n\n>>> netifaces.gateways()\n{2: [('10.0.1.1', 'en0', True), ('10.2.1.1', 'en1', False)], 30: [('fe80::1', 'en0', True)], 'default': { 2: ('10.0.1.1', 'en0'), 30: ('fe80::1', 'en0') }}\n\nThis dictionary is keyed on address family---in this case, ``AF_INET``---and\neach entry is a list of gateways as ``(address, interface, is_default)`` tuples.\nNotice that here we have two separate gateways for IPv4 (``AF_INET``); some\noperating systems support configurations like this and can either route packets\nbased on their source, or based on administratively configured routing tables.\n\nFor convenience, we also allow you to index the dictionary with the special\nvalue ``'default'``, which returns a dictionary mapping address families to the\ndefault gateway in each case. Thus you can get the default IPv4 gateway with\n\n>>> gws = netifaces.gateways()\n>>> gws['default'][netifaces.AF_INET]\n('10.0.1.1', 'en0')\n\nDo note that there may be no default gateway for any given address family;\nthis is currently very common for IPv6 and much less common for IPv4 but it\ncan happen even for ``AF_INET``.\n\nBTW, if you're trying to configure your machine to have multiple gateways for\nthe same address family, it's a very good idea to check the documentation for\nyour operating system *very* carefully, as some systems become extremely\nconfused or route packets in a non-obvious manner.\n\nI'm very interested in hearing from anyone (on any platform) for whom the\n``gateways()`` method doesn't produce the expected results. It's quite\ncomplicated extracting this information from the operating system (whichever\noperating system we're talking about), and so I expect there's at least one\nsystem out there where this just won't work.\n\n3. This is great! What platforms does it work on?\n--------------------------------------------------\n\nIt gets regular testing on OS X, Linux and Windows. It has also been used\nsuccessfully on Solaris, and it's expected to work properly on other UNIX-like\nsystems as well. If you are running something that is not supported, and\nwish to contribute a patch, please use BitBucket to send a pull request.\n\n4. What license is this under?\n------------------------------\n\nIt's an MIT-style license. Here goes:\n\nCopyright (c) 2007-2014 Alastair Houghton\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n5. Why the jump to 0.10.0?\n--------------------------\n\nBecause someone released a fork of netifaces with the version 0.9.0.\nHopefully skipping the version number should remove any confusion. In \naddition starting with 0.10.0 Python 3 is now supported and other \nfeatures/bugfixes have been included as well. See the CHANGELOG for a\nmore complete list of changes.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/GNS3/netifaces", "keywords": null, "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "gns3-netifaces", "package_url": "https://pypi.org/project/gns3-netifaces/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/gns3-netifaces/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/GNS3/netifaces" }, "release_url": "https://pypi.org/project/gns3-netifaces/0.10.4.1/", "requires_dist": null, "requires_python": null, "summary": "Portable network interface information. GNS3 fork for solving a Python 3 issue", "version": "0.10.4.1" }, "last_serial": 1579958, "releases": { "0.10.4.1": [ { "comment_text": "", "digests": { "md5": "b0d7847d5ceeca95dbe31d5c1df86468", "sha256": "9cfb497ab91d6865ecbfd6aa2361a0a3b952e97ef2f334d5f9945cb3a119b720" }, "downloads": -1, "filename": "gns3-netifaces-0.10.4.1.tar.gz", "has_sig": false, "md5_digest": "b0d7847d5ceeca95dbe31d5c1df86468", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27079, "upload_time": "2015-06-05T13:51:10", "url": "https://files.pythonhosted.org/packages/7b/ad/5e36bf0944b29cc7a75281c114cb630b0c1db98f4fa38ef57266f46356d6/gns3-netifaces-0.10.4.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b0d7847d5ceeca95dbe31d5c1df86468", "sha256": "9cfb497ab91d6865ecbfd6aa2361a0a3b952e97ef2f334d5f9945cb3a119b720" }, "downloads": -1, "filename": "gns3-netifaces-0.10.4.1.tar.gz", "has_sig": false, "md5_digest": "b0d7847d5ceeca95dbe31d5c1df86468", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27079, "upload_time": "2015-06-05T13:51:10", "url": "https://files.pythonhosted.org/packages/7b/ad/5e36bf0944b29cc7a75281c114cb630b0c1db98f4fa38ef57266f46356d6/gns3-netifaces-0.10.4.1.tar.gz" } ] }