Skip to main content

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.

Warning

This is the new upstream for python-ethtool maintained by Fedora’s Python SIG. We ported it to Python 3 and only maintain it for the current tools to keep working. No new development is happening. This is a deprecated package. If you are considering to start using this, please don’t. We recommend netifaces instead.

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.

Authors

  • Andy Grover
  • Antoni S. Puimedon
  • Arnaldo Carvalho de Melo
  • Bohuslav Kabrda
  • Braňo Náter
  • Dave Malcolm
  • David S. Miller
  • David Sommerseth
  • Harald Hoyer
  • Charalampos Stratakis
  • Jeff Garzik
  • Lumir Balhar
  • Miro Hrončok
  • Miroslav Suchý
  • Ruben Kerkhof
  • Sanqui
  • Yaakov Selkowitz

Current maintainers

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.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
ethtool-0.14.tar.gz (43.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page