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.


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 install


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')

The ethtool package also provides the pethtool and pifconfig utilities. More example usage may be gathered from their sources, and

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
      inet addr:   Mask:
          inet6 addr: ::1/128 Scope: host

Further usage information may be found in the respective manpages for pethtool and pifconfig.


Tests may be run by tox.


  • 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


Feel free to help us with improving test coverage, porting to Python 3 or anything else. Issues and PRs on GitHub are welcome.


The Python ethtool project is free software distributed under the terms of the GNU General Public License v2.0, see COPYING.



Thu Jul 29 2021 Lumír Balhar <>

  • 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


Wed Sep 12 2018 Miro Hrončok <>

  • 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


Tue Jun 13 2017 Miro Hrončok <>

  • First release on PyPI

  • Supports both Python 2.7 and 3.5+

  • Dropped support for Python 2.6

  • Upstream URL changed to

  • Introduced a basic README file

  • PEP7 and PEP8 (code style) improvements

  • Fix compilation errors on modern Fedoras


Tue Mar 21 2017 Charalampos Stratakis <>

  • First attempt at python3 support


Thu May 8 2014 David Sommerseth <>

  • Improved error handling several places

  • Ensure that we get a valid libnl NETLINK connection when connecting

  • URL updates to SPEC file


Fri Jan 10 2014 David Sommerseth <>

  • Not really a full release, but a preliminary release to get more wide testing

  • FSF Copyright updates

  • Build fixes

  • Mostly code cleanup


Wed Dec 11 2013 David Sommerseth <>

  • Fixed get_active_devices() for IPv6 only interfaces

  • Moved from libnl1 to libnl3

  • Refactor PyNetlink*Address implementation


Tue Feb 19 2013 David Malcolm <>

  • Enable IPv6 in pifethtool example

  • Code cleanup, fixing buffer overflows, memory leaks, etc


Mon Apr 11 2011 David Sommerseth <>

  • 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)


Wed Jan 19 2011 David Sommerseth <>

  • 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 (Miroslav Suchy)


Mon Aug 9 2010 David Sommerseth <>

  • Fixed double free issue (commit c52ed2cbdc5b851ebc7b)


Wed Apr 28 2010 David Sommerseth <>

  • 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()


Tue Aug 26 2008 Arnaldo Carvalho de Melo <>

  • Add get_flags method from the first python-ethtool contributor, yay

  • Add pifconfig command, that mimics the ifconfig tool using the bindings available


Wed Aug 20 2008 Arnaldo Carvalho de Melo <>

  • Expand description and summary fields, as part of the fedora review process.


Tue Dec 18 2007 Arnaldo Carvalho de Melo <>

  • Get ethtool code from rhpl 0.212

Download files

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

Source Distribution

ethtool-0.15.tar.gz (44.9 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page