Python module to interface with ethtool
Project description
Python ethtool module
Python bindings for the ethtool kernel interface
The Python ethtool module allows querying and partially controlling network interfaces, driver, and hardware settings.
Installation
The easiest way to install ethtool is to use your distribution packages repositories. For example:
Fedora: sudo dnf install python3-ethtool or sudo dnf install python2-ethtool
Ubuntu: sudo apt install python-ethtool
In order to install ethtool from source or PyPI install its dependencies first:
Fedora: sudo dnf install libnl3-devel gcc redhat-rpm-config python3-devel
Ubuntu: sudo apt install python3 python3-setuptools libpython3.6-dev libnl-route-3-dev
And then install ethtool:
from PyPI: pip3 install ethtool
from source: python3 setup.py install
Usage
ethtool may be used as a Python library:
>>> import ethtool >>> ethtool.get_active_devices() ['lo', 'enp0s31f6', 'wlp4s0', 'virbr0', 'docker0', 'virbr1', 'eth0', 'tun0'] >>> ethtool.get_ipaddr('lo') '127.0.0.1'
The ethtool package also provides the pethtool and pifconfig utilities. More example usage may be gathered from their sources, pethtool.py and pifconfig.py.
pethtool mimics behavior of the ethtool utility, but does not support all options.
e.g., to get driver information on the eth0 interface:
$ pethtool -i eth0 driver: cdc_ether bus-info: usb-0000:00:14.0-4.1.3
Analogically, pifconfig mimics ifconfig in usage. It may be used to view information on an interface:
$ pifconfig lo lo inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope: host UP LOOPBACK RUNNING
Further usage information may be found in the respective manpages for pethtool and pifconfig.
Tests
Tests may be run by tox.
Current maintainers
Lumír Balhar <lbalhar@redhat.com>
Miro Hrončok <mhroncok@redhat.com>
Charalampos Stratakis <cstratak@redhat.com>
Contributing
Feel free to help us with improving test coverage, porting to Python 3 or anything else. Issues and PRs on GitHub are welcome.
License
The Python ethtool project is free software distributed under the terms of the GNU General Public License v2.0, see COPYING.
Changelog
0.15
Thu Jul 29 2021 Lumír Balhar <lbalhar@redhat.com>
Tests are now skipped for wireguard devices
pifconfig is now able to show more than one IPv4 address per interface
pifconfig supports interfaces with no IPv4 address
0.14
Wed Sep 12 2018 Miro Hrončok <mhroncok@redhat.com>
Declared project as bugfix only from now on
Support Python 3.7
Fix important issues reported by static analysis
Fix installation on non-UTF-8 locales on Python 3.5 and 3.6
Added set_gso(), get_gro() and set_gro() functions
Added installation instructions
0.13
Tue Jun 13 2017 Miro Hrončok <mhroncok@redhat.com>
First release on PyPI
Supports both Python 2.7 and 3.5+
Dropped support for Python 2.6
Upstream URL changed to https://github.com/fedora-python/python-ethtool
Introduced a basic README file
PEP7 and PEP8 (code style) improvements
Fix compilation errors on modern Fedoras
0.12
Tue Mar 21 2017 Charalampos Stratakis <cstratak@redhat.com>
First attempt at python3 support
0.11
Thu May 8 2014 David Sommerseth <davids@redhat.com>
Improved error handling several places
Ensure that we get a valid libnl NETLINK connection when connecting
URL updates to SPEC file
0.10
Fri Jan 10 2014 David Sommerseth <davids@redhat.com>
Not really a full release, but a preliminary release to get more wide testing
FSF Copyright updates
Build fixes
Mostly code cleanup
0.9
Wed Dec 11 2013 David Sommerseth <davids@redhat.com>
Fixed get_active_devices() for IPv6 only interfaces
Moved from libnl1 to libnl3
Refactor PyNetlink*Address implementation
0.8
Tue Feb 19 2013 David Malcolm <dmalcolm@redhat.com>
Enable IPv6 in pifethtool example
Code cleanup, fixing buffer overflows, memory leaks, etc
0.7
Mon Apr 11 2011 David Sommerseth <davids@redhat.com>
Fixed several memory leaks (commit aa2c20e697af, abc7f912f66d)
Improved error checking towards NULL values(commit 4e928d62a8e3)
Fixed typo in pethtool –help (commit 710766dc722)
Only open a NETLINK connection when needed (commit 508ffffbb3c)
Added man page for pifconfig and pethtool (commit 9f0d17aa532, rhbz#638475)
Force NETLINK socket to close on fork() using FD_CLOEXEC (commit 1680cbeb40e)
0.6
Wed Jan 19 2011 David Sommerseth <davids@redhat.com>
Don’t segfault if we don’t receive any address from rtnl_link_get_addr()
Remove errornous file from MANIFEST
Added ethtool.version string constant
Avoid duplicating IPv6 address information
import sys module in setup.py (Miroslav Suchy)
0.5
Mon Aug 9 2010 David Sommerseth <davids@redhat.com>
Fixed double free issue (commit c52ed2cbdc5b851ebc7b)
0.4
Wed Apr 28 2010 David Sommerseth <davids@redhat.com>
David Sommerseth is now taking over the maintenance of python-ethtool
New URLs for upstream source code
Added new API: ethtool.get_interfaces_info() - returns list of etherinfo objects
Added support retrieving for IPv6 address, using etherinfo::get_ipv6_addresses()
0.3
Tue Aug 26 2008 Arnaldo Carvalho de Melo <acme@redhat.com>
Add get_flags method from the first python-ethtool contributor, yay
Add pifconfig command, that mimics the ifconfig tool using the bindings available
0.2
Wed Aug 20 2008 Arnaldo Carvalho de Melo <acme@redhat.com>
Expand description and summary fields, as part of the fedora review process.
0.1
Tue Dec 18 2007 Arnaldo Carvalho de Melo <acme@redhat.com>
Get ethtool code from rhpl 0.212
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ethtool-0.15.tar.gz
.
File metadata
- Download URL: ethtool-0.15.tar.gz
- Upload date:
- Size: 44.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 567260ea5805063bbcff71dabd6fb820f89bc84f720e9ebe315c7eef1449d908 |
|
MD5 | 11bb2dea653286c245794829b389e952 |
|
BLAKE2b-256 | d2592137996ee2da077e9369ac323830938bfc14083049081d89fdd7f3cf20a5 |