Registry / http-networking / netifaces2

netifaces2

JSON →
library0.0.22pypypi✓ verified 82d ago

netifaces2 is a Python library providing portable access to network interface information. It is a fork of the original `netifaces` library, offering improved support, particularly for Windows, and is actively maintained. The current version is 0.0.22, with recent updates focusing on stability and new features like listing interfaces by name and index, enhancing Windows compatibility.

pip install netifaces2
INSTALL
IMPORT
SIG · NETIFACES2
N
netifaces2
http-networkingpythonv0.0.22
Install
1.6s avg
Import
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.22 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22.1MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 22MB
20MB installed
● package 20MB
Code
Verified usage

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

interfaces
from netifaces import interfaces
import netifaces2
AF_INET
from netifaces import AF_INET
import netifaces2
gateways
from netifaces import gateways
import netifaces2

This example demonstrates how to list all network interfaces and retrieve their IPv4, IPv6, and MAC addresses using `netifaces2`.

import netifaces2 print(f"All interfaces: {netifaces2.interfaces()}") for i in netifaces2.interfaces(): print(f"\nInterface: {i}") addrs = netifaces2.ifaddresses(i) if netifaces2.AF_INET in addrs: for link in addrs[netifaces2.AF_INET]: print(f" IPv4: {link.get('addr')}") if netifaces2.AF_INET6 in addrs: for link in addrs[netifaces2.AF_INET6]: print(f" IPv6: {link.get('addr')}") if netifaces2.AF_LINK in addrs: for link in addrs[netifaces2.AF_LINK]: print(f" MAC: {link.get('addr')}")
Debug
Known issues
gotchaUsers migrating from the original `netifaces` library might mistakenly install or import `netifaces` instead of `netifaces2`. These are distinct packages, and `netifaces2` is the actively maintained fork.
fix
Always use `pip install netifaces2` and `import netifaces2` in your code.
affects: All
gotchaOn Windows, prior to version 0.0.22, users might encounter stability issues, including potential unbounded memory allocations, particularly on complex network setups.
fix
Ensure you are running netifaces2 version 0.0.22 or newer for improved Windows stability by running `pip install --upgrade netifaces2`. Report specific issues to the GitHub repository.
affects: <0.0.22 (Windows only)
gotchaNetwork interface names can vary significantly across operating systems (e.g., 'eth0', 'en0', 'Local Area Connection'). Hardcoding interface names can lead to non-portable code.
fix
Use `netifaces2.interfaces()` to dynamically get a list of available interfaces and iterate through them, or use platform-specific logic to resolve common interface names.
affects: All
Upgrade
Version history
0.0.22latest on PyPI · released Feb 28, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
netifaces2 — pip install netifaces2 · libregistry