Skip to main content
pyroute2
========

Python network configuration library

PyRoute2 uses Netlink protocol to communicate with the Linux kernel
and get/set all the information kernel network objects.

todo
====

* VLAN linkinfo data
* bridge info: see `./net/bridge/br_netlink.c:br_fill_ifinfo()`
* traffic control -- work with queue disciplines

iproute
=======

Old-style library, that provides access to rtnetlink as is. It
helps you to retrieve and change almost all the data, available
through rtnetlink.

from pyroute2 import iproute
ip = iproute()
# lookup interface by name
dev = ip.link_lookup(ifname='tap0')[0]
# bring it down
ip.link('set', dev, state='down')
# change interface MAC address and rename it
ip.link('set', dev, address='00:11:22:33:44:55', ifname='vpn')
# add primary IP address
ip.addr('add', dev, address='10.0.0.1', mask=24)
# add secondary IP address
ip.addr('add', dev, address='10.0.0.2', mask=24)
# bring it up
ip.link('set', dev, state='up')

ipdb
====

Experimental module, that provides high-level API to network
configuration. It represents network objects as a transactional
database with commit/rollback. It is far not production ready,
so be prepared for surprises and API changes.

from pyroute2 import ipdb
ip = ipdb()
ip.tap0.down()
ip.tap0.address = '00:11:22:33:44:55'
ip.tap0.ifname = 'vpn'
ip.tap0.ipaddr.add(('10.0.0.1', 24))
ip.tap0.ipaddr.add(('10.0.0.2', 24))
ip.tap0.commit()
ip.vpn.up()

If you want to review and/or rollback the transaction, you can
use code like that:

from pprint import pprint
...
pprint(ip.tap0.review())
{'attrs': {'address': 'da:72:48:6b:13:c8 -> 00:11:22:33:44:55',
'ifname': 'tap0 -> vpn'},
'ipaddr': ['+10.0.0.4/24',
'+10.0.0.5/24',
'+10.0.0.2/24',
'+10.0.0.3/24',
'+10.0.0.1/24']}
ip.tap0.rollback()

Actually, the form like 'ip.tap0.address' is an eye-candy. The
ipdb objects are dictionaries, so you can write the code above
as that:

ip['tap0'].down()
ip['tap0']['address'] = '00:11:22:33:44:55'
ip['tap0']['ifname'] = 'vpn'
...

Also, interface objects can operate as context managers:

with ip.tap0 as i:
i.address = '00:11:22:33:44:55'
i.ifname = 'vpn'
i.ipaddr.add(('10.0.0.1', 24))
i.ipaddr.add(('10.0.0.1', 24))

On exit, the context manager will authomatically commit the
transaction.

taskstats
=========

All that you should know about taskstats, is that you should not
use it. But if you have to, ok:

import os
from pyroute2 import taskstats
ts = taskstats()
ts.get_pid_stat(os.getpid())

It is not implemented normally yet, but some methods are already
usable.

installation
============

make install

requires
========

Python >= 2.6

changes
=======

* 0.1.3
* ipdb: context manager interface
* ipdb: [fix] correctly handle ip addr changes in transaction
* ipdb: [fix] make up()/down() methods transactional [#1]
* iproute: mirror packets to 0 queue
* iproute: [fix] handle primary ip address removal response
* 0.1.2
* initial ipdb version
* iproute fixes
* 0.1.1
* initial release, iproute module

links
=====

* home: https://github.com/svinota/pyroute2
* bugs: https://github.com/svinota/pyroute2/issues
* pypi: https://pypi.python.org/pypi/pyroute2

Metadata

Release files for pyroute2 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyroute2 0.1.3
File Size Uploaded Provenance
pyroute2-0.1.3.tar.gz 28.6 kB Without provenance Details

Release files / pyroute2-0.1.3.tar.gz

Download URL pyroute2-0.1.3.tar.gz
Size 28.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a73d68e41c81bc9538ebe0afab9236e72fcb9e5c657e4c3c4c83215450324c94
BLAKE2b-256 checksum
How to use checksums
f6451be6723f2cf08ee357c760cef0cc4722f734c3e49646a774e9f55a5677ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyroute2 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

0.3.17

This release

0.1.3 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page