Bound packet captures and preserve useful network evidence

Bound packet captures and preserve useful network evidence

Bound packet captures and preserve useful network evidence

When a dedicated server hosting multiple sites suffers intermittent disconnections and application logs show only timeouts, the most useful response is not to keep recording everything on the network interface. It is to preserve interpretable packet evidence around a specific failure. Unbounded captures consume disk space and may collect login credentials, request bodies, and other sites’ data. A capture suitable for handoff needs limits on the interface, traffic peers, bytes saved per packet, file storage, and runtime.

The examples below use Ubuntu 24.04 and tcpdump. They require sudo privileges and installed copies of tcpdump, iproute2, and coreutils. Credentials for AmdCli servers are available in the console after payment; use the first IPv4 for SSH management connections. This procedure does not change network configuration or require service restarts.

1. Define the failure you need to establish

Before starting, record the failure time and time zone, the client address, the target service port, and application logs for both successful and failed requests. Narrow the objective to a specific question, such as “Did the client send a connection request, and did the server respond?” rather than a vague instruction to “check the network.”

The capture point determines what the evidence covers: a physical network interface sees traffic passing through that interface; loopback traffic may appear only on lo; and traffic passing through a bridge or address translation may use different addresses at different points. Check interfaces and routes first instead of guessing from interface names:

ip -br address
ip route show
tcpdump --version

This article covers a single TCP peer. If the peer connects through a proxy or address translation, enter the address the server actually sees, not the local address of the device running the browser. Take the service port from the application’s actual configuration; do not assume default ports for SSH or the application service.

Treat capture files as sensitive material. A shorter snapshot length does not anonymize the data, and TLS encryption does not hide IP addresses, packet lengths, or communication timing.

2. Prepare a minimal filter and a private directory

Run the following steps in the same Bash session. Enter the interface, peer IP, and port when prompted; the port must be the numeric value actually in use. The directory is created in the current user’s home directory, with no access granted to other accounts:

umask 077
CAPDIR=$(mktemp -d "$HOME/pcap.XXXXXXXX")
read -r -p "Interface: " IFACE
read -r -p "Peer IP: " PEER
read -r -p "TCP port: " PORT
FILTER="tcp and host $PEER and port $PORT"
sudo tcpdump -i "$IFACE" -d "$FILTER" > "$CAPDIR/filter.txt"

The last command only compiles the filter expression; it does not start capturing. If it fails, check the input before proceeding. Next, validate the filter with a real, successful request. If it produces no results, check the interface, address, and protocol first rather than immediately expanding the capture to all traffic.

The filter matches both requests and responses for the specified port, but only records packets passing through the selected interface. If the failure occurs during domain name resolution or a non-TCP exchange, this filter cannot answer the relevant question. Define a separate collection scope for that case.

3. Limit storage, runtime, and permissions together

The following example saves the first 96 bytes of each packet, rotates files at approximately 10 MB, uses no more than four files, and sends an interrupt signal after 120 seconds. All numbers are parameters for this diagnostic session, not service commitments:

date -Is > "$CAPDIR/start.txt"
ip -s link show dev "$IFACE" > "$CAPDIR/link-before.txt"
sudo timeout --signal=INT 120s \
  tcpdump -i "$IFACE" -nn -s 96 -U \
  -C 10 -W 4 -Z "$(id -un)" \
  -w "$CAPDIR/traffic.pcap" "$FILTER" \
  2> "$CAPDIR/capture.stats"
date -Is > "$CAPDIR/end.txt"
ip -s link show dev "$IFACE" > "$CAPDIR/link-after.txt"

-nn disables address and port name resolution so the diagnostic process does not introduce additional lookup traffic. -Z switches to the current user account after initialization; that account must be able to access the directory. -U writes packets to the file more promptly, but does not guarantee data integrity after a sudden power loss.

-C measures size in decimal millions of bytes, and rotation checks occur at packet boundaries. Four files therefore provide a budget of roughly 40 MB, not a strict disk quota. The ring overwrites older content, and the last file at the end of the capture is not necessarily the largest. File name sequence numbers alone cannot establish the complete chronological order.

When the time limit is reached, timeout normally returns 124. This means the time boundary was triggered and should not automatically be recorded as a capture failure. You still need to check the statistics file and confirm that the output files are readable. If the program does not respond to the interrupt, check the original process before starting another capture process.

4. Distinguish collection gaps from actual network problems

After capture ends, check file sizes and program statistics first, then select a file to read offline. Enter its path from the actual file listing:

ls -lh "$CAPDIR"
cat "$CAPDIR/capture.stats"
read -r -p "Capture file path: " PCAP
tcpdump -nn -tttt -r "$PCAP" -c 40

Use a successful request as a baseline, then compare connection establishment, acknowledgments, and connection closure around the failure time. An observation at a single capture point is not, by itself, a root-cause finding:

  • Seeing a request without a response only establishes that no response was recorded at that capture point. Filtering, routing, and service-side processing still need investigation.
  • Repeated sequence numbers may indicate retransmissions, but must be assessed alongside timing and packets in both directions.
  • packets dropped by kernel usually means the capture program did not read buffered packets quickly enough. It does not mean packets were lost on the public network link.
  • Checksum errors may result from network interface offloading. A local capture of outbound traffic alone is not enough to conclude that packets are corrupt.

The before-and-after interface statistics cover the entire interface, not just the target connection. They provide supporting evidence, but should not be directly compared by subtracting the filtered packet count. If capture-side drops increase, first narrow the target scope and reduce interference from the application workload, then consider adjusting the buffer.

5. Validate the evidence and restrict access

96 bytes may be too short to preserve longer protocol headers, yet may already include application content from short packets. If full packets are genuinely needed, establish authorization, a disk budget, and the permitted transfer scope before running a separate capture. Do not make -s 0 a routine default.

The handoff should include, at minimum: the failure time and time zone, capture interface and location, filter, snapshot length, start and end times, capture statistics, and corresponding application errors. Generate a checksum manifest for the files you ultimately retain:

(
  cd "$CAPDIR" &&
  sha256sum traffic.pcap* > SHA256SUMS &&
  sha256sum -c SHA256SUMS
)

Hashes help detect file changes after handoff; they do not encrypt or sanitize the contents. Keep access to original files restricted, and check sensitive fields before sharing copies. If address mappings need explanation, store the mapping table separately from the capture.

Finally, confirm that the capture process has exited, check whether ring overwrites removed the lead-up to the failure, and verify that every retained file can be read offline. If the material is insufficient, explicitly document the evidence gaps and arrange a more targeted capture rather than expanding the scope indefinitely. A capture is complete when it supports a verifiable conclusion, not when it leaves behind more files.

Frequently asked questions

Does a small snaplen guarantee that a capture contains no secrets?

No. Short packets can still contain application data, while IP addresses and communication patterns remain visible. Restrict file access and review the contents before sharing.

Does kernel dropped prove packet loss on the public network?

No. It generally counts packets that the capture program did not read from its buffer in time. Narrow the filter and compare host load, interface counters and application symptoms.

AMD EPYC 7543P Dedicated Server

From $463.8/month, with no setup fee or contract.

Configure an AmdCli dedicated server View AmdCli pricing

Compare server configurations and options

Choose memory, bandwidth, and IPv4 options to configure an AmdCli dedicated server for deployment needs.