pyroute2
Python Netlink library
Decision gist · record as of 2026-08-14
Yes, if you need programmatic Linux network configuration on Python 3.9+. The library is actively maintained, has no known vulnerabilities, and low install friction. However, verify the dual GPL/Apache license terms for your use case first, and confirm that the unclear license treatment does not conflict with your project's licensing requirements. Not suitable for non-Linux platforms.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Linux; emulates limited RTNL API on BSD but is not supported on other platforms.
- Requires Python >= 3.9.
- Low install friction; distributed as a pure Python wheel with only one runtime dependency (win_inet_pton).
License · maintenance · safety
GPL-2.0-or-later OR Apache-2.0 (unclear) — Dual-licensed under GPL-2.0-or-later OR Apache-2.0, but license treatment is marked unclear. Verify which license terms apply to your use case before integrating into proprietary or commercial projects.
last release 2026-04-15 (121 days) · last repo commit 2026-06-22 · 1,064 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,390,171 downloads/mo, #3,966 on PyPI
Alternatives
Verify before relying
pip install pyroute2
from pyroute2 import IPRoute
ipr = IPRoute()
for link in ipr.get_links():
print(link)
ipr.close()- Exact scope of BSD emulation support and which RTNL operations are available on non-Linux systems.
- Performance characteristics and scalability limits when handling large numbers of netlink messages or network state changes.
What it is and what it does
Pyroute2 is a pure Python networking framework that exposes Linux netlink protocols for programmatic control of network configuration. It started as an RTNL (routing netlink) implementation but now supports multiple protocol families including DHCP, netfilter, generic netlink, and others. The core requires only Python's standard library, with a single optional dependency for Windows compatibility.
The library offers three main APIs: IPRoute for low-level synchronous netlink access (link/address/route manipulation), AsyncIPRoute for asyncio-based operations, and NDB for high-level transactional network state management with commit/rollback semantics. It handles network namespace management, virtual interface creation, firewall rules, traffic control, and hardware monitoring through a unified Python interface.
Use it for
- Automate Linux network configuration (interfaces, routes, addresses) in infrastructure or container orchestration tools.
- Implement network namespace isolation and virtual network topology setup for containerization or testing.
- Build firewall rule management or packet filtering applications using netfilter and nftables APIs.
- Monitor and react to network state changes via netlink event subscriptions.
- Manage VPN or wireless network configuration programmatically through wireguard and nl80211 APIs.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need programmatic Linux network configuration on Python 3.9+.
The library is actively maintained, has no known vulnerabilities, and low install friction. However, verify the dual GPL/Apache license terms for your use case first, and confirm that the unclear license treatment does not conflict with your project's licensing requirements. Not suitable for non-Linux platforms.
Install
pyroute2 on PyPI
Before you install
Low install friction; distributed as a pure Python wheel with only one runtime dependency (win_inet_pton). Actively maintained with recent commits and no known vulnerabilities.
Requires Linux; emulates limited RTNL API on BSD but is not supported on other platforms. Requires Python >= 3.9.
License in practice
Dual-licensed under GPL-2.0-or-later OR Apache-2.0, but license treatment is marked unclear. Verify which license terms apply to your use case before integrating into proprietary or commercial projects.
Quickstart
pip install pyroute2
from pyroute2 import IPRoute
ipr = IPRoute()
for link in ipr.get_links():
print(link)
ipr.close()
Verify before relying
- Exact scope of BSD emulation support and which RTNL operations are available on non-Linux systems.
- Performance characteristics and scalability limits when handling large numbers of netlink messages or network state changes.
Package facts
| License | GPL-2.0-or-later OR Apache-2.0 unclear |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagewin_inet_pton |
| Maintenance | Actively maintained 121 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,390,171 / month, #3,966 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: System AdministratorsIntended Audience :: Telecommunications IndustryOperating System :: POSIX :: LinuxProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTopic :: System :: NetworkingTopic :: System :: Systems Administration |
Evidence: pyroute2-0.9.6-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “linux netlink socket programming”
- pyroute2Pyroute2 is a pure Python networking framework that provides direct…
- btsocketA Python library for controlling BlueZ Bluetooth adapters on Linux…
- PyRICPyRIC provides programmatic control over Linux wireless interfaces,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also PyRIC · netaddr · netifaces · pyobjc-framework-MultipeerConnectivity · icmplib · ipaddr · pyobjc-framework-Network · python3-dtls · pyRFXtrx · netifaces-plus