--- id: pyroute2 version: "0.9.6" license: GPL-2.0-or-later OR Apache-2.0 license_treatment: unclear maintenance: active --- # pyroute2 — Python Netlink library License: unclear · Maintenance: active · Downloads: 1.4M/mo ## 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 above — verify before relying. Pyroute2 is a pure Python networking framework that provides direct access to Linux netlink protocols for configuring network interfaces, routes, firewall rules, and other system networking resources. 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 pip install pyroute2 uv add pyroute2 poetry add pyroute2 ## Installing pyroute2 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. 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() Requires Linux; emulates limited RTNL API on BSD but is not supported on other platforms. Requires Python >= 3.9. 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_current - Install friction: low - Maintenance: active - Downloads: 1.4M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags linux netlink socket programming, network interface configuration python, routing table manipulation, firewall rule management, network namespace management, netlink-socket, linux-networking, infrastructure-automation [View on SkillFed](https://skillfed.io/packages/pyroute2) · [View on PyPI](https://pypi.org/project/pyroute2/)