Skip to main content

Prettify and enrich ifconfig output: aligned tables, IP/MAC/scope annotations, OUI vendor lookup, live DNS/DHCP/route, and a 1h bandwidth graph.

Project description

ifpretty

Prettify and enrich ifconfig output — aligned tables, color, decoded flags, IP/MAC/scope annotations, OUI vendor lookup, live DNS/DHCP/route, a 1‑hour bandwidth graph, and run‑to‑run diffing. Built on rich.

ifpretty

The default is an essentials view: identity, routable IPs (with scope), gateway and throughput, with down / address‑less interfaces collapsed to one line. Pass -v for every field.

Install

pip install ifpretty

Requires Python ≥ 3.9. The only dependency is rich.

Usage

ifpretty                       # essentials view; runs `ifconfig` for you
ifpretty -v                    # verbose: every field + expand collapsed interfaces
ifpretty en0 en6               # limit to one or more interfaces
ifconfig | ifpretty            # or pipe ifconfig in yourself

ifpretty -r                    # --records : compact label/value record layout
ifpretty -t                    # --table   : single wide table, all fields (<=240 cols)

ifpretty -l                    # --live    : route, traffic, friendly names, DNS, DHCP (macOS)
ifpretty -c                    # --check   : ping the default gateway for latency (macOS)
ifpretty -w                    # --wan     : public IP / ASN / geo (opt-in; sends IP to ipapi.co)
ifpretty -d                    # --diff    : show what changed since the previous run
ifpretty -x                    # --explain : append a legend for the flags/options seen
ifpretty --map                 # open an interactive browser map of your network
ifpretty --map 8.8.8.8         # …tracing the route to a specific target

ifpretty --record              # sample byte counters (run via cron to feed the 1h graph)
ifpretty --update-oui          # refresh the IEEE vendor database into the cache

Run it bare and it runs ifconfig for you; or pipe ifconfig in to control which interfaces to show. Flags compose (e.g. ifpretty -l -d -w).

What it adds

Always on (offline, deterministic):

  • Per‑interface role (loopback / Ethernet·Wi‑Fi / VPN·tunnel / bridge / …).
  • IP scope for every address — loopback / link‑local / ULA / private / global — plus IPv4 network + usable‑host count.
  • MAC kind (universal vs locally‑administered), OUI vendor (bundled IEEE registry, no network), shared‑MAC notes (e.g. bridge members), and EUI‑64 detection.
  • Media speed/duplex with a half‑duplex ⚠ warning; jumbo / sub‑1280 MTU notes.
  • Decoded flag/option/nd6 bitfields; IPv6 attributes aligned into columns.
  • A one‑line overview above the layout (interface count, default route, totals).

--live (macOS, cross‑references the system):

  • Default route + gateway, friendly hardware‑port names, per‑interface DNS and search domains, DHCP server + lease, traffic counters (bytes + packets) and error/collision counts.

--check: pings the default gateway and reports latency / unreachable.

--wan (external, opt‑in): looks up your public IP plus ASN/ISP/geo via ipapi.co and shows it in the overview. It sends your public IP to a third party, so it is strictly opt‑in; the result is cached ~1 h, times out fast, and degrades silently offline. --update-oui refreshes the vendor database from the IEEE registry into the cache (overrides the bundled copy).

--diff: every run records a snapshot of the stable interface state (up/down, addresses, MAC, mtu, media, gateway — not volatile counters) to snapshot.json. With --diff, ifpretty prints what changed since the previous run — interfaces added/removed, status flips, added/removed IPv4/IPv6 addresses — before the normal view.

1‑hour bandwidth graph: schedule the recorder, then per‑interface Unicode sparklines (and a link‑utilization gauge) appear automatically:

# once, e.g. in `crontab -e` — use the absolute path:
* * * * * $(command -v ifpretty) --record
1h in    ▁▁▁▂▄█▅▂▁▁▁▁   peak 10.0 Mbps
1h out   ▁▂▂▄▆█▄▂▂▁▁▁   peak 533.3 Kbps
link use ████░░░░░░     40% of 1000 Mbps

--map (browser visualization): opens an interactive graph of your network — this host and its interfaces, the LAN devices/peripherals each interface talks to (from the ARP table, labelled by OUI vendor), the default gateway, and the traceroute path out to the internet (default target 1.1.1.1, or pass one). Rendered with vis-network (loaded from a CDN) into a self-contained HTML file that opens automatically in your browser.

Environment

  • NO_COLOR=1 disables color; CLICOLOR_FORCE=1 forces it when piped.
  • IFPRETTY_HISTORY — bandwidth‑samples file (default ~/.cache/ifpretty/samples.csv).
  • IFPRETTY_CACHE — cache directory for the WAN lookup, refreshed OUI DB, and the diff snapshot (default ~/.cache/ifpretty/).

--live / --check / --record use macOS tools (route, netstat, networksetup, scutil, ipconfig, ping) and no‑op (or degrade) elsewhere; the parsing, formatting and offline enrichment work wherever you can pipe ifconfig output in.

Architecture

The package is split into focused modules (one responsibility each):

Module Responsibility
model dataclasses Inet / Inet6 / Interface
parse raw ifconfig text → interface model
enrich derivations, OUI, system (--live/--check), history, --wan, snapshot/diff
formatting model values → styled (rich‑markup) strings; layout field rows
render render strategies (boxed / records / table) + overview / legend / diff
topology --map: traceroute + ARP → vis-network HTML graph in the browser
cli acquire input → parse → enrich → render

Dependency direction: model ← parse, enrich ← formatting ← render ← cli (no cycles).

Development

python3 -m unittest discover -s tests   # 67 tests (snapshot + unit)
ruff check src tests && mypy src

Layout snapshots are pinned to golden files; regenerate intentionally with REGEN=1 python3 tests/test_ifpretty.py.

License

MIT

Project details


Download files

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

Source Distribution

ifpretty-0.9.0.tar.gz (421.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ifpretty-0.9.0-py3-none-any.whl (411.1 kB view details)

Uploaded Python 3

File details

Details for the file ifpretty-0.9.0.tar.gz.

File metadata

  • Download URL: ifpretty-0.9.0.tar.gz
  • Upload date:
  • Size: 421.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for ifpretty-0.9.0.tar.gz
Algorithm Hash digest
SHA256 c0941c5dc5bac66878a4dacb3aa2cbe3cf3dc9f591b406742181644e105cb906
MD5 6358e5a14f0c0b79e141cde306a0fb25
BLAKE2b-256 32bdeef97b04092c1c3e22363e0f02671fa328e639e01e9f3a135a091d884510

See more details on using hashes here.

File details

Details for the file ifpretty-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: ifpretty-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 411.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for ifpretty-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96ef3145de9e9d3341dc42b7cd8ee868374128d6d5873efadabe24d0a42370cd
MD5 2087c32617184ca3c5ac4b23bb4ae362
BLAKE2b-256 2f1d866970136a136ec9900742901a4a47cbef21c0a5917ac79efa47fe694f60

See more details on using hashes here.

Supported by

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