Skip to main content
https://travis-ci.org/ssudake21/ifconfig-parser.svg?branch=master

Parse ifconfig output collected from local or remote server and retrieve required interface information.

Usage

Install ifconfig-parser:

pip install -U ifparser

You can access inferface information as below :

>>> import commands
>>> from ifparser import Ifcfg
>>> ifdata = Ifcfg(commands.getoutput('ifconfig -a'))
>>> ifdata.interfaces
['lo', 'docker0', 'eth0']
>>> eth0 = ifdata.get_interface('eth0')
>>> eth0.BROADCAST
True
>>> eth0.hwaddr, eth0.mtu, eth0.ip, eth0.UP
('08:00:27:1f:d8:b0', '1500', '10.0.2.15', True)

You can query for intefaces on particular parameter :

 >>> ifdata.get(itype='Ethernet')
 [obj-docker0, obj-eth0]
 >>> ifdata.get(UP=True)
[obj-lo, obj-docker0, obj-eth0]

Get all interface parameters with get_values. Following dictionary contains all possible values:

>>> eth0 = ifdata.get_interface('eth0')
>>> eth0.get_values()
{'BROADCAST': True,
 'LOOPBACK': False,
 'MULTICAST': True,
 'RUNNING': True,
 'UP': True,
 'bcast': '10.10.2.255',
 'hwaddr': 'FF:FF:27:1f:d8:b0',
 'interface': 'eth0',
 'ip': '10.10.2.15',
 'itype': 'Ethernet',
 'mask': '255.255.255.0',
 'mtu': '1500',
 'rxbytes': '547873',
 'rxpkts': '628',
 'txbytes': '50826',
 'txpkts': '424'}

List of parameters for interface:

  • BROADCAST, LOOPBACK, MULTICAST, RUNNING, UP, DYNAMIC, NOARP, PROMISC, POINTTOPOINT, SIMPLEX, SMART, MASTER, SLAVE

  • interface - Interface name, itype - Interface Type

  • ip - IP, bcast - Broadcast, mask - Mask

  • hwaddr - MAC address, mtu - MTU

  • rxbytes - Received Bytes, rxpkts - Received Packets

  • txbytes - Sent Bytes, txpkts - Sent Packets

Release files for ifparser 0.8.1

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

Source distribution (sdist)

Source distribution for ifparser 0.8.1
File Size Uploaded
ifparser-0.8.1.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ifparser 0.8.1
File Interpreter ABI Platform
ifparser-0.8.1-py2-none-any.whl Python 2 none any Details

Total release size: 14.4 kB

Release files / ifparser-0.8.1.tar.gz

Download URL ifparser-0.8.1.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
22ca426469f58d47be5d8fe10e4a4934b21b4eb166f79766da95f77072d0d8d4
BLAKE2b-256 checksum
How to use checksums
02c5489f5791d9e21e10f308f59acf02301995778fe9a11d2497baf2995abb4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.19.6 CPython/2.7.15rc1

Release files / ifparser-0.8.1-py2-none-any.whl

Download URL ifparser-0.8.1-py2-none-any.whl
Size 8.2 kB
Tags Python 2
SHA-256 checksum
How to use checksums
1e5819e1f1c725cc919f64f372403ebce99f86543366a37ec267755d41b13994
BLAKE2b-256 checksum
How to use checksums
f802045784a0141b98265539335a9a1850e15335ff95307c3af07994192b9a2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.19.6 CPython/2.7.15rc1

Release history Release notifications | RSS feed

0.8.2

1 release file

This release

0.8.1 This release

2 release files

0.8.0

2 release files

0.7.0

1 release file

0.6.0

1 release file

0.5.0

2 release files

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

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