net-monitor

module
v0.3.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2026 License: MIT

README

Net Monitor

Simple terminal network monitor. It captures packets from an active network interface and shows aggregated connection statistics in the console.

Requirements

  • Go 1.22 or newer
  • libpcap on macOS/Linux, or Npcap on Windows
  • Permissions to capture network packets

On macOS/Linux, packet capture usually requires sudo.

Install

With Go
go install github.com/ikondratev/net-monitor/cmd/net-monitor@v0.3.8

Or install the latest tagged release:

go install github.com/ikondratev/net-monitor/cmd/net-monitor@latest

Make sure Go's bin directory is in your PATH:

export PATH="$HOME/go/bin:$PATH"

Check the installed version:

net-monitor -v

Run:

sudo net-monitor

List available interfaces:

net-monitor -si

Capture from a specific interface:

sudo net-monitor -i en0

Usage

Supported flags:

Flag Description
-v Print version and exit.
-si Show available network interfaces and exit.
-i <name> Capture from a specific network interface.
--interface <name> Same as -i.
-p <port> Filter TCP/UDP traffic by port.
--proto <tcp|udp|icmp> Filter traffic by protocol.
--host <ip> Filter traffic by host IP address.
--bpf <filter> Use a custom BPF filter. Overrides the generated filter.
--dump <pcap|json> Write captured packets to stdout instead of starting the UI.
--limit <count> Stop after capturing this many packets. Use with --dump to create bounded captures.

Filter by protocol, host, or port:

sudo net-monitor --proto tcp
sudo net-monitor --host 192.0.2.10
sudo net-monitor -p 443

Use a custom BPF filter:

sudo net-monitor --bpf "tcp and host 192.0.2.10 and port 443"

Dump captured packets to a pcap file:

sudo net-monitor --bpf "tcp and port 443" --dump pcap --limit 100 > traffic.pcap

Dump captured packets as NDJSON (one JSON object per line):

sudo net-monitor --proto tcp --dump json --limit 50 > traffic.json

Inspect the JSON dump with jq:

cat traffic.json | jq .

Read the saved capture with tcpdump:

tcpdump -nn -r traffic.pcap

Build Locally

go build -o bin/net-monitor ./cmd/net-monitor

Check the embedded version:

./bin/net-monitor -v

Run:

sudo ./bin/net-monitor

Directories

Path Synopsis
cmd
net-monitor command
lib
app
Package app wires packet capture, statistics aggregation, and the UI.
Package app wires packet capture, statistics aggregation, and the UI.
cli
Package cli parses net-monitor command-line flags and runs the application
Package cli parses net-monitor command-line flags and runs the application
consoleui
Package consoleui renders terminal UI for net-monitor.
Package consoleui renders terminal UI for net-monitor.
netcapture
Package netcapture opens a network interface and streams packets with BPF filtering.
Package netcapture opens a network interface and streams packets with BPF filtering.
netdevice
Package netdevice discovers network interfaces available for packet capture.
Package netdevice discovers network interfaces available for packet capture.
netdump
Package netdump writes captured packets to stdout in pcap or JSON format.
Package netdump writes captured packets to stdout in pcap or JSON format.
netinterface
Package netinterface defines connection identity and traffic statistics types.
Package netinterface defines connection identity and traffic statistics types.
netstats
Package netstats aggregates captured packets into per-connection statistics.
Package netstats aggregates captured packets into per-connection statistics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL