Linux How to Monitor Network Traffic Hands-On Guide
A production link is saturated, latency is climbing, and the bandwidth graph only says that something is busy. The first response is usually a quick interface check. The harder question arrives seconds later: which connection, process, container, or workload caused the traffic, and is the current symptom a capacity problem, packet loss, retransmission storm, or something else?
Linux offers tools for each layer, but no single command provides the whole answer. ip -s link and nload show interface pressure, iftop exposes active conversations, nethogs connects traffic to processes, tcpdump supplies packet-level evidence, and persistent collectors turn short-lived spikes into trends. Modern fleets also need to account for namespaces, overlays, encryption, and the overhead of observing busy links.
Table of Contents
- Why Linux Network Traffic Monitoring Still Matters
- Core Toolkit for Live Throughput and Connection Views
- Capturing Packets the Right Way With tcpdump and BPF
- Finding Which Process Caused the Traffic
- From Counters to Dashboards Sampling Aggregation and Alerting
- Choosing the Right Approach and Making It Stick
Why Linux Network Traffic Monitoring Still Matters
At 3am, a saturated interface can make unrelated systems look broken. Requests time out, backup jobs slow down, and health checks fail while CPU and memory remain normal. A live rate confirms pressure, but it does not identify whether a batch job, noisy neighbor, retry loop, or damaged network path created the load.
That makes network monitoring an operational control, not a decorative dashboard. The practical approach described in this network monitoring overview connects traffic measurements with the context needed to act. A rate shows how much traffic is moving. A connection view shows between whom. Correlation with processes, containers, and workloads shows who caused it.
Live evidence versus durable telemetry
Linux exposes complementary evidence through interface counters, socket state and packet capture. The kernel interface-statistics guide explains the counter families and their limits. Historical collection is a separate deployment task; interactive commands alone do not retain yesterday's incident.
Live tools support incident response. They expose current ingress and egress, active conversations, and whether a spike affects one interface or the whole host. Their evidence is transient, though. Once the event ends, they cannot show whether the same burst returns during backups, releases, or scheduled data transfers.
Historical telemetry answers that longer question. vnStat runs as a background daemon, records transfer continuously, and keeps summarized measurements across several retention horizons, including five-minute, hourly, daily, and yearly views. The exact retention behavior depends on its configuration and version, so operators should verify it in the official vnStat documentation. This design preserves useful counters without an interactive session and supports trend analysis, billing, and capacity planning on modest servers.
Operational rule: Use live views to determine what is happening now. Use retained counters to determine whether the event is normal, recurring, or nearing a capacity limit.
The required depth follows the incident. A brief slowdown may need interface counters and ss. Recurring saturation calls for historical collection. A suspected data leak or retransmission storm may justify a narrowly filtered packet capture, while sampling, aggregation, or eBPF can associate traffic with processes at lower overhead than storing every packet. Treating every problem as either a dashboard issue or a full capture wastes time and can add avoidable load to an already busy host.
Core Toolkit for Live Throughput and Connection Views
Start with counters before starting a sniffer. The command below gives interface totals, including errors and drops, so it provides more useful first evidence than a bandwidth graph alone:
ip -s link
For a single interface, operators can inspect /proc/net/dev twice, with a one-second interval, and calculate the byte delta. nload presents a live ingress and egress rate for one interface, while bmon is more useful when several interfaces need simultaneous comparison. These tools answer whether the link is busy and in which direction, not which workload owns the traffic.
The next layer is connection visibility. iftop groups traffic by active connection, tcptrack focuses on TCP sessions, and nethogs attributes bandwidth to processes. ifstat provides a compact interface-rate view that works well in terminals and scripts. For historical interface sampling, sar -n DEV retains readings that can help separate a transient burst from sustained pressure. A broader Linux network monitor guide describes this layered ecosystem, including vnStat, iftop, nethogs, bmon, ifstat, and tcptrack.

Escalation by question
A useful operator doesn't run every tool at once. The following mapping keeps the investigation focused:
| Question to Answer | Best Tool | What It Shows |
|---|---|---|
| Have interface counters changed? | ip -s link at two times |
Cumulative bytes, errors and drops; calculate rates before assessing utilization |
| What rate is moving now? | nload |
Live ingress and egress for an interface |
| Which interface is busiest? | bmon |
Comparative real-time interface activity |
| Which hosts or connections dominate? | iftop |
Active conversations and their bandwidth |
| Which process owns the traffic? | nethogs |
Process-level bandwidth usage |
| Are TCP sessions retransmitting? | ss -ti |
Socket details and TCP diagnostics |
| Is there retained interface history? | sar -n DEV or vnStat |
Sampled or aggregated traffic over time |
iftop helps identify remote peers contributing to observed traffic; use its port display when connection-level detail is needed. The linked NeoTeo overview of OpenNetMeter concerns a Windows tool, so it is optional cross-platform context rather than a Linux installation recommendation.
Don't stop when the rate looks high. Check link counters for errors and drops, then inspect TCP state with:
ss -ti
A busy interface can be healthy, while a moderately busy interface with retransmissions can be the source of application failures. The throughput measurement guide provides useful context for treating rate, direction, and sustained behavior as separate measurements rather than collapsing them into one graph.
Calculate a rate without confusing units
This executable example uses hypothetical counters, not live measurements:
def mbps(before_bytes, after_bytes, seconds):
if seconds <= 0:
raise ValueError("Elapsed time must be positive")
if after_bytes < before_bytes:
raise ValueError("Counter reset or discontinuity: resample")
return (after_bytes - before_bytes) * 8 / seconds / 1_000_000
print(mbps(1_000_000_000, 1_125_000_000, 10)) # 100.0 Mbit/s
For a nominal 1 Gbit/s link, 100 Mbit/s is approximately 10% in that direction. Do not sum receive and transmit percentages as though full-duplex capacity were shared. Do not add physical, bridge and veth counters without checking for double counting. A ten-second average can hide a much shorter burst; use drop/queue evidence and an appropriate sampling interval to investigate saturation.
Capturing Packets the Right Way With tcpdump and BPF
At 3 a.m., a saturated link leaves little room for guesswork. tcpdump preserves packet-level evidence, exposing headers, flags, handshakes, retransmissions, and, where permitted, payload data. It can also save that evidence for later analysis. Raw capture is costly, though, so it is a poor default for indefinite collection on a busy production interface.
Start by finding the available interfaces:
sudo tcpdump -D
Choose the relevant interface, then narrow the capture with a Berkeley Packet Filter:
sudo timeout 30s tcpdump -p -ni eth0 -nn -s 96 -c 100 \
'host 192.0.2.10 and port 443'
Filter on the dimensions that answer the investigation: host, port, protocol, or a combination. Early filtering reduces inspection and storage work, keeps the capture readable, and limits exposure of unrelated traffic. The tcpdump command-line introduction documents this interface-first, filter-driven workflow.

Capture narrowly and preserve evidence
Give every capture a defined question and bounded scope:
sudo timeout 30s tcpdump -p -ni eth0 -nn -s 96 -c 200 \
'tcp and host 192.0.2.10 and port 443'
Replace eth0 and the documentation-only address with an approved interface and target. These Linux commands require GNU timeout and tcpdump. They print bounded samples rather than writing unlimited full packets into /tmp. -p avoids requesting promiscuous mode, -nn suppresses address/port name conversion, -s 96 limits snapshot length and -c limits packet count; timeout caps elapsed time. A short snapshot can still include sensitive data and may omit diagnostic fields. A hostname in the filter would still need initial resolution, so numeric filters avoid that dependency.
Capturing has overhead and can drop packets under load. Check tcpdump's final captured/received/dropped counters and preserve the filter, interface and timestamps. If a pcap is needed, use a restricted directory, bounded file rotation and retention, and review who can access it. Never treat an incomplete capture as proof that an exchange did not occur.
Practical rule: Make the capture answer one defined question. Select one interface, filter early, use a short collection window, and stop once the evidence is sufficient.
Capture visibility is limited by namespaces, overlays and encryption. NIC segmentation/checksum offload can make a host-side trace differ from packets on the wire, so apparent bad checksums are not automatically corruption. Capturing on any, bridge and veth layers can also create duplicate observations. Keep the selected observation point explicit. For a broader view, see network monitoring on Linux, the Ethernet monitoring guide and the secondary LinuxSecurity discussion of monitoring gaps. These do not change the limits of a particular capture point.
The following media provides a visual reference for the command-line workflow and packet inspection context.
Finding Which Process Caused the Traffic
At 3 a.m., a saturated interface tells you the symptom, not the offender. eth0 may be transmitting heavily and a remote peer may dominate a connection, but an IP address is not a process identity. On a shared host, that address can represent several services, containers, or users. Interface counters alone cannot show which workload initiated the transfer.
Pair the socket table with a process-level view:
sudo ss -tinp
sudo nethogs -d 2
ss -tinp displays TCP information and available process ownership without resolving numeric endpoints; -p is the process option. Permissions and the current network namespace affect visibility. nethogs associates observed traffic with processes where it can, but short-lived sockets and namespaces can limit attribution.

Correlate sockets, namespaces, and workloads
After identifying a suspicious socket, trace it to the owning process through its file descriptors:
pid=1234 # Replace with the actual process ID.
sudo ls -l "/proc/$pid/fd" | grep 'socket:'
sudo cat "/proc/$pid/cgroup"
sudo readlink "/proc/$pid/ns/net"
These commands inspect descriptors, cgroup identity and network namespace without dumping the process command line, which may contain secrets. An exited PID can disappear during inspection; reconcile with the same timestamped socket sample. In an authorized namespace investigation, nsenter can run read-only socket inspection in the target network namespace, but it requires appropriate privileges and care about the selected PID.
Use these checks:
- Inspect the cgroup: Identify the service, container, or workload group associated with the PID.
- Inspect the namespace: Compare the process network namespace with the host and neighboring workloads.
- Confirm the endpoint: Match local ports, remote peers, and TCP state with
ss. - Check the workload owner: Connect the cgroup or namespace to the deployment, job, or tenant responsible for it.
Security-focused Linux coverage frames attribution as correlation across network flow, host telemetry, and detection context. A top-talker report without process, namespace, or workload context leaves remediation unresolved.
The right response depends on ownership. A backup worker may need scheduling or rate control. An application producing retransmissions needs service or network diagnosis, while bandwidth limits would only hide the symptom. Sampling process activity, aggregating it by executable and workload, and using eBPF can preserve attribution with less data than full packet capture. Capture remains preferable when exact packet contents or protocol behavior must be examined.
From Counters to Dashboards Sampling Aggregation and Alerting
CLI commands are excellent during an incident, but they can't establish a durable baseline. Continuous monitoring needs a collection path that preserves enough detail to diagnose a problem without turning every packet into a long-term storage obligation.
vnStat retains interface-usage history when its daemon is configured and running. sar -n DEV 1 5 samples live interface rates; historical sar output requires an enabled sysstat collector and existing activity files. An exporter exposes metrics but normally relies on a scraper/database for long-term retention. Verify the collector, storage and query path independently; metrics and dashboards should document those dependencies.

Choose the resolution before choosing the dashboard
Sampling is a design decision, not a cleanup task. High-resolution measurements help explain short bursts, but they create more data and more alert noise. Aggregated counters preserve capacity trends and recurring patterns, but they can hide a brief event that caused an outage.
A workable pipeline separates those purposes:
- Collect the raw counters. Read interface bytes, errors, drops, and TCP indicators. Add process or workload labels where the collector can obtain them safely.
- Scrape or push selected measurements. Export host and interface metrics to the existing monitoring system. Use SNMP for network devices when interface health must be viewed alongside Linux hosts.
- Retain multiple views. Keep short-window detail for incident investigation and aggregated history for planning, billing, and recurring-pattern analysis.
- Alert on symptoms with context. Combine sustained utilization with errors, drops, retransmissions, or service impact instead of paging on one instantaneous rate.
The retention model should match the decision being supported. Capacity planning needs comparable history across interfaces and workloads. Incident response needs enough temporal detail to align traffic with deployments, jobs, and application failures. Billing or tenant accountability needs consistent aggregation and an identity that survives process restarts.
Make alerts actionable
A useful alert should tell the responder what changed and where to look next. An interface-utilization alert without direction, errors, or workload labels creates a ticket that still requires manual reconstruction. A better event includes the interface, traffic direction, related drops or retransmissions, the responsible service when available, and a link to the relevant dashboard.
Fivenines server monitoring retains host network metrics, while SNMP device monitoring polls supported interface tables through a local collector. Verify the configured and effective cadence for each source; a chart aggregation interval is not necessarily a collection interval. Neither interface counters nor an SNMP dashboard identify every process or capture packet payloads.
Keep packet captures out of the default retention path unless there is a clear security or troubleshooting requirement. Counters and sampled flow data usually provide a lower-overhead foundation, while narrowly filtered captures remain an escalation tool. That separation keeps the monitoring system useful during an incident instead of making the observability pipeline another source of pressure.
Choosing the Right Approach and Making It Stick
The right Linux traffic-monitoring method depends on three constraints: what must be explained, how long the evidence must survive, and how much overhead the host can tolerate.
For a quick traffic check, use ip -s link, nload, or bmon; determine saturation from rates, effective capacity and queue/drop evidence. For a top-talker investigation, move to iftop. For process ownership, use nethogs and socket inspection. For packet behavior, apply a narrow tcpdump filter. For recurring trends, retain summarized counters with vnStat, sampled history with sar, or centralized metrics from exporters and SNMP.
A practical decision checklist
- Need a fast answer: Start with interface counters and connection views.
- Need root-cause ownership: Correlate sockets with PIDs, cgroups, namespaces, and containers.
- Need packet evidence: Identify the interface first, then capture only the relevant host, port, or protocol.
- Need historical planning: Store aggregated counters and preserve enough detail to compare recurring windows.
- Need fleet-wide context: Centralize host, interface, and network-device metrics with consistent labels.
- Need modern workload coverage: Evaluate kernel-native observability where overlays, churn, or encrypted east-west traffic limit packet-capture value.
Packet capture, flow telemetry and eBPF instrumentation answer different questions and have different visibility and overhead limits. There is no defensible universal percentage of traffic missed by all conventional tools. Choose instrumentation from the required protocols, kernels, namespaces and evidence, and benchmark it on a representative workload before rollout.
Decision principle: Stay with counters and targeted tools when the environment is small and the question is narrow. Invest in process-aware, kernel-native observability when the fleet is containerized, multi-tenant, or difficult to inspect through interfaces alone.
Automation makes the choice durable. Define collectors, dashboards, alert policies, and labels through APIs or Terraform, then test alerts against real traffic conditions. A runbook should state which command to run first, which evidence justifies escalation, and how to identify the workload before anyone throttles or restarts a service.
Fivenines combines Linux host metrics, interface traffic, SNMP device monitoring, per-container context, dashboards, and alert routing in one platform, with HTTPS-based agent telemetry and API or Terraform management. Visit Fivenines to connect network traffic visibility with the rest of the infrastructure signals needed during the next saturation incident.