Linux Networking Diagnostics: iproute2, Socket Telemetry (ss), tcpdump, mtr & ethtool
Created: 2026-11-06 · Last updated: 2026-11-13 · Nejat Hakan
Executive Summary: Legacy
net-toolsutilities (ifconfig,netstat,route,arp) have been deprecated for over fifteen years: they rely on inefficient/proc/nettext parsing, conceal secondary IPv4/IPv6 CIDR addresses, lack policy routing capabilities, and cannot inspect modern kernel TCP congestion metrics (cwnd,rtt,retrans). This enterprise operational guide covers the Netlink-powerediproute2suite (ip,ss,bridge), kernel socket diagnostics viaSOCK_DIAG, Path MTU Discovery (PMTUD) &mtrlatency profiling, hardware NIC tuning withethtool, packet capture usingtcpdumpand BPF filters, and millisecond-accurate Layer-7 timing dissection viacurl -w.
-
Netlink
iproute2vs.net-tools
Replace deprecated
ifconfigand/proc/netstring scraping with high-performance binary kernel Netlink sockets (AF_NETLINK). -
Link Layer, CIDR & Policy Routing
Diagnose hardware FIFO overrun drops (
ip -s -s link), manage secondary CIDR addresses, and orchestrate policy-based routing withip rule. -
Socket Forensics & TCP Internals (
ss)
Detect listen backlog saturations (
Recv-Q > Send-Q), inspect kernel TCP congestion telemetry (cwnd,rtt,retrans), and tear down hangs viass -K. -
BPF Packet Capture (
tcpdump)
Filter wire-level frames inside the kernel using BPF bytecode before Netfilter, capture rotating PCAP ring buffers, and stream live traces to Wireshark.
-
Path Telemetry, PMTUD &
ethtool
Isolate Path MTU blackholes (
ping -M do), analyze multi-hop loss withmtr, and resize network interface DMA ring buffers to prevent packet loss. -
Application Layer & DNS Diagnostics
Inspect
systemd-resolvedwithresolvectl, trace authoritative delegations usingdig +trace, and dissect HTTP/TLS latencies into phases viacurl -w.
1. Linux Network Architecture & CLI Evolution: Netlink vs. Deprecated net-tools
In enterprise Linux systems engineering, relying on legacy net-tools commands (ifconfig, netstat, route, arp) poses significant operational and diagnostic risks:
- Inefficient String Parsing in
/proc/net:netstatreads sequentially through pseudo-files such as/proc/net/tcp. On busy production nodes handling 50,000 concurrent sockets, this causes severe kernel lock contention and high userspace CPU burn. - Concealment of Secondary IP Addresses: Developed prior to Linux 2.2,
ifconfigcannot represent genuine secondary IP addresses assigned to a single interface. When multiple IPv4 or IPv6 CIDRs are assigned,ifconfigdisplays only the primary address unless deprecated IP aliases (eth0:1) are manually configured. - No Support for Network Namespaces or Policy Routing:
net-toolspossesses zero awareness of Linux network namespaces (ip netns), policy-based routing tables, or modern virtual interfaces (veth pairs, VRFs, WireGuard). - Blind to TCP Congestion Internals: Neither
netstatnorifconfigcan extract kernel TCP metrics such as RTT variance, congestion window size (cwnd), or active congestion control states (CUBIC, BBR).
Netlink (AF_NETLINK) & The iproute2 Architecture
The modern iproute2 suite (ip, ss, bridge, tc) communicates via the kernel socket family AF_NETLINK (NETLINK_ROUTE and NETLINK_INET_DIAG). Rather than parsing flat text files, iproute2 exchanges binary C structures atomically with the kernel. This delivers sub-millisecond query responses even on hosts with hundreds of thousands of active sockets.
%%{init: {'flowchart': {'wrappingWidth': 350}}}%%
flowchart TB
subgraph UserspaceTools ["1. CLI Diagnostic Utilities"]
direction TB
IPSS["ip / ss / bridge<br/>(iproute2 Suite)"]
TCPDump["tcpdump -nn -i eth0<br/>(BPF Bytecode Filter)"]
IPSS --> TCPDump
end
subgraph KernelNet ["2. Kernel Network Stack"]
direction TB
Netlink["AF_NETLINK Socket API<br/>(RTNETLINK / SOCK_DIAG)"]
PacketTap["AF_PACKET / dev_add_pack<br/>(Packet Tap BEFORE Netfilter)"]
Netfilter["Netfilter / nftables<br/>(PREROUTING & Filtering)"]
FIBRoute["FIB Routing & L4 Stack<br/>(Routing Lookup & Sockets)"]
Netlink --> PacketTap --> Netfilter --> FIBRoute
end
subgraph HardwareStage ["3. Drivers & Hardware"]
direction TB
NICRing["NIC RX/TX DMA Ring<br/>(NAPI Poll + sk_buff)"]
end
UserspaceTools ==> KernelNet
KernelNet ==> HardwareStage
Rosetta Stone Migration Matrix
Deprecated net-tools Command |
Modern iproute2 Equivalent |
Operational Advantage in Production |
|---|---|---|
ifconfig -a |
ip -br -c addr show |
Concise, colorized summary of all CIDRs (IPv4/IPv6) and link states. |
ifconfig eth0 up/down |
ip link set dev eth0 up/down |
Atomic interface state modification without interface aliasing. |
route -n |
ip route show |
Exposes all routes, metrics, and scopes across the main routing table. |
route add default gw 1.1.1.1 |
ip route add default via 1.1.1.1 |
Supports multipath routing, MTU locking, and secondary routing tables. |
arp -an |
ip neigh show |
Displays both IPv4 ARP and IPv6 NDP neighbor states (REACHABLE, STALE, FAILED). |
netstat -tulnp |
ss -tulnp |
Extracts socket states via Netlink 10× to 50× faster than /proc/net. |
netstat -s |
nstat -az or ip -s -s link |
Atomic network protocol statistics queried directly from kernel memory. |
2. Link Layer, Interface Telemetry & Policy Routing (ip link, ip addr, ip route)
The ip command serves as the primary administrative tool for managing Layer-2 and Layer-3 network operations in the Linux kernel.
Link-Layer Inspection (ip link)
Audit physical and virtual network interfaces, MAC addresses, and Layer-2 link states:
# 1. Compact tabular overview of all interfaces with status (UP/DOWN/LOWER_UP)
ip -br link show
# 2. Detailed hardware error, drop, and FIFO overrun counters
ip -s -s link show dev eth0
RX: bytes packets errors dropped missed mcast
1428590 12480 0 5 0 0
RX errors: length crc frame fifo overrun
0 0 0 5 0
dropped: Packets dropped by the kernel (e.g., memory allocation failures or missing protocol handlers).
* fifo / overrun: The NIC's hardware DMA ring buffer filled up before the kernel's NAPI polling routine (softirq) could process frames. This indicates CPU core 0 saturation or an undersized NIC ring buffer (see Chapter 5: ethtool).
* Security Audit (Promiscuous Mode Detection):
An interface in PROMISC state processes all frames on the Layer-2 collision domain (indicative of packet sniffers or unauthorized capture tools):
IP Address Management & DAD (ip addr)
Under Linux, multiple IPv4 and IPv6 addresses can be assigned to a single interface without aliasing:
# 1. Colorized overview of all IPv4 and IPv6 addresses
ip -c addr show dev eth0
# 2. Assign a secondary IPv4 address dynamically
sudo ip addr add 192.168.10.50/24 dev eth0
# 3. Remove secondary address
sudo ip addr del 192.168.10.50/24 dev eth0
- IPv6 Duplicate Address Detection (DAD): When assigning an IPv6 address, the kernel transmits Neighbor Solicitation frames to verify address uniqueness across the local segment.
- If
ip addrdisplaystentative, DAD verification is in progress. - If
ip addrdisplaysdadfailed, an address collision was detected and the kernel disables the interface IP to prevent packet hijacking.
Kernel FIB Routing & Policy-Based Routing (ip route)
Never guess which path an egress packet will select—query the kernel's Forwarding Information Base (FIB) directly using ip route get:
# Simulates routing for a destination and returns egress interface, source IP, and gateway
ip route get 8.8.8.8
-
Policy-Based Routing (PBR): By default, Linux routes all egress packets using a single table (
table main). For multi-homed servers (e.g., eth0 for management, eth1 for data traffic), configure dedicated routing tables:Configuring policy-based routing with custom tables# 1. Register a named routing table in /etc/iproute2/rt_tables echo "200 custom_traffic" | sudo tee -a /etc/iproute2/rt_tables # 2. Define the default route inside the custom table sudo ip route add default via 10.0.0.1 dev eth1 table custom_traffic # 3. Create a policy rule: traffic originating from 10.0.0.50 evaluates custom_traffic sudo ip rule add from 10.0.0.50/32 table custom_traffic ip rule show -
The Reverse Path Filtering Trap (
rp_filter): If an ingress packet arrives oneth1, but the host routing table would route the reply out viaeth0(asymmetric routing), the kernel silently drops the packet ifrp_filter=1(Strict Mode) is enabled:In multi-homed, containerized, and VPN architectures, set# Check rp_filter mode (0 = disabled, 1 = strict, 2 = loose) sysctl net.ipv4.conf.all.rp_filter net.ipv4.conf.eth1.rp_filterrp_filterto2(Loose Mode).
3. Layer 4 Socket Forensics & TCP Congestion Telemetry (ss)
The ss (Socket Statistics) command leverages the kernel's INET_DIAG module to extract socket state tables directly from kernel memory. It is the premier diagnostic tool for troubleshooting port collisions, listen backlog overflows, and TCP throughput degradation.
Rapid Triage and Socket State Filtering
# 1. List all listening TCP and UDP sockets with process names, PIDs, and file descriptors
sudo ss -tulnp
# 2. Print summary socket statistics grouped by protocol state
ss -s
# 3. Filter all active (ESTABLISHED) TCP connections destined for a specific CIDR
ss -t state established dst 10.0.0.0/8
Listen Backlog Mechanics: Send-Q vs. Recv-Q
For listening TCP sockets (ss -lnt), Send-Q and Recv-Q carry completely different semantics than for established connections:
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 129 128 0.0.0.0:443 0.0.0.0:*
Send-Q: The maximum capacity of the listen backlog (requested by the application via listen(fd, backlog) and clamped by the kernel via net.core.somaxconn).
* Recv-Q: The number of completed 3-way handshakes currently waiting in the kernel queue that have not yet been accepted by the application via accept()!
* Incident Warning: If Recv-Q > Send-Q, the listen backlog is saturated. Egress clients will experience connection timeouts or TCP SYN retransmissions because the application worker threads are blocked or exhausted.
In-Depth TCP Socket Telemetry (ss -t -i)
Passing the -i flag exposes internal kernel TCP metrics (struct tcp_info):
cubic wscale:7,7 rto:204 rtt:0.125/0.035 ato:40 mss:1448 rcvspace:14600
ssthresh:110 cwnd:10 ssthresh:110 bytes_acked:14820 bytes_received:4210
seg_out:24 seg_in:18 data_segs_out:12 data_segs_in:6 send 92.7Mbps
retrans:0/1 rcvrtt:1.2 delivery_rate 124.5Mbps
cubic / bbr: Active TCP congestion control algorithm.
* rtt:0.125/0.035: Smoothed Round-Trip Time (0.125 ms) and RTT variance (0.035 ms jitter).
* cwnd:10: Congestion Window size in packets (how many unacknowledged segments the host can transmit).
* retrans:0/1: Number of TCP retransmissions over the connection lifecycle.
* delivery_rate: Real-time throughput calculated by the kernel pacing layer.
Terminating Hung TCP Sockets via Kernel Reset (ss -K)
When an orphaned process or deadlock holds a network socket open, terminate the socket directly inside the kernel (transmitting TCP RST packets to both endpoints) without restarting daemons:
# Forcibly closes an established TCP connection to a remote database node
sudo ss -K dst 192.168.1.150 dport = 3306
4. Packet Capture & BPF Filter Engineering (tcpdump)
When firewall rules, TLS negotiation handshakes, or routing protocols fail silently, tcpdump delivers wire-level ground truth.
The AF_PACKET Tap Architecture
tcpdump attaches an AF_PACKET socket to the kernel driver using dev_add_pack:
* Ingress Traffic (RX): tcpdump captures frames BEFORE evaluation by nftables/iptables. If tcpdump observes incoming SYN packets, but client requests time out, the packet is being blocked by a local firewall rule or rp_filter!
* Egress Traffic (TX): tcpdump captures frames AFTER passing through Netfilter.
Production Capturing Rules
Always execute tcpdump in production with these baseline flags:
* -nn: Disables reverse DNS lookups and port name translations. Omitting -nn causes synchronous DNS lookups that stall packet capture, filling the socket buffer and dropping packets (dropped by kernel).
* -s 0: Captures the full packet payload (snapshot length: unlimited).
* -tttt: Prints standardized, microsecond-accurate human-readable timestamps.
* -i any: Listens on all interfaces concurrently (including loopback and virtual bridges).
Precise BPF Expressions (Berkeley Packet Filter)
BPF filter expressions compile to in-kernel bytecode; only packets matching the filter are copied into userspace:
# 1. Capture only initial TCP SYN packets (connection attempts) on port 443
sudo tcpdump -nn -i eth0 'tcp[tcpflags] & (tcp-syn) != 0 and tcp[tcpflags] & (tcp-ack) == 0 and port 443'
# 2. Intercept TCP RST packets (connection terminations by firewall or crash)
sudo tcpdump -nn -i eth0 'tcp[tcpflags] & (tcp-rst) != 0'
# 3. Capture verbose DNS queries and responses on port 53
sudo tcpdump -nnvv -i any 'port 53'
# 4. Capture ICMP Path MTU Discovery Fragmentation-Needed frames
sudo tcpdump -nn -i eth0 'icmp[icmptype] == 3 and icmp[icmpcode] == 4'
Rotating Ring Buffers & Wireshark Streaming
Never stream unbounded packet captures into a single file. Utilize a rotating ring buffer:
# Creates up to 5 files of 100 MB each (-C 100 -W 5) in a ring buffer
sudo tcpdump -nn -i eth0 -s 0 -C 100 -W 5 -w /var/log/traffic-capture.pcap 'port 443'
To inspect traffic on a headless remote server directly using your local Wireshark graphical interface, pipe raw capture streams over SSH:
ssh root@remote-server.corp "tcpdump -nn -s 0 -U -w - -i eth0 'not port 22'" | wireshark -k -i -
5. Path Diagnostics, MTU Discovery & Hardware Quality (ping, mtr, iperf3, ethtool)
Network throughput and reliability degradation frequently stem from intermediate hop constraints (MTU mismatches, transit packet loss) or physical NIC buffer exhaustion.
Path MTU Discovery (PMTUD) & Blackhole Detection
Standard Ethernet specifies a Maximum Transmission Unit (MTU) of 1500 bytes. When intermediate encapsulation tunnels (WireGuard, IPsec, GRE, VXLAN) reduce available MTU, packets exceeding the MTU must be fragmented. If an application sets the DF (Don't Fragment) bit in the IP header, the router must discard the packet and return an ICMP Type 3, Code 4 (Fragmentation Needed) message.
If an intermediate firewall blocks this ICMP packet, a PMTUD Blackhole occurs: small packets (TCP 3-way handshake) pass cleanly, but large packets (TLS certificates, bulk payload transfers) stall indefinitely.
# Formula: 1472 bytes payload + 20 bytes IPv4 header + 8 bytes ICMP header = 1500 MTU
# -M do enforces the DF bit; -s defines ICMP payload size
ping -c 3 -M do -s 1472 1.1.1.1
message too long, mtu=1420, reduce payload size incrementally (1392 + 28 = 1420) to discover the exact bottleneck MTU across the path.
Continuous Multi-Hop Path Analysis with mtr
Standard traceroute tests each hop only three times and cannot reliably assess asymmetric paths. mtr (My Traceroute) combines traceroute topology discovery with continuous ping telemetry:
# 1. Interactive terminal analysis using ICMP
mtr 8.8.8.8
# 2. Generate a 10-cycle report using TCP probes on port 443 (bypassing ICMP filters)
mtr --report --report-cycles 10 --tcp -P 443 nejat-hakan.de
HOST: edge-router-01 Loss% Snt Last Avg Best Wrst StDev
1.|-- 192.168.1.1 0.0% 10 0.3 0.4 0.3 0.6 0.1
2.|-- 10.254.0.1 0.0% 10 1.2 1.4 1.1 2.1 0.3
3.|-- 62.154.55.12 60.0% 10 15.4 16.1 14.9 22.0 2.2
4.|-- 217.239.52.42 0.0% 10 14.8 15.0 14.6 16.2 0.5
5.|-- nejat-hakan.de 0.0% 10 15.1 15.2 14.8 16.5 0.5
Hardware NIC Diagnostics with ethtool
Audit and configure physical network interfaces at the driver and firmware layer:
# 1. Inspect negotiated link speed, duplex mode, and auto-negotiation
sudo ethtool eth0
# 2. View current and maximum hardware RX/TX DMA ring buffer limits
sudo ethtool -g eth0
# 3. Increase ring buffers to hardware maximum (e.g., 4096) to eliminate buffer drops
sudo ethtool -G eth0 rx 4096 tx 4096
# 4. Audit active hardware offloading features (TSO, GSO, GRO, Checksumming)
sudo ethtool -k eth0
Throughput and Jitter Testing with iperf3
# On target server (receiver):
iperf3 -s
# On client node: 4 concurrent TCP streams for 15 seconds
iperf3 -c 192.168.1.200 -P 4 -t 15
# UDP mode to measure true jitter and packet loss at 100 Mbps target bandwidth
iperf3 -c 192.168.1.200 -u -b 100M -t 10
6. Application Layer & DNS Troubleshooting (resolvectl, dig, curl, socat/nc)
When Layer 3 routing and Layer 4 sockets are confirmed functional, application timeouts and latency spikes almost invariably trace to DNS resolution issues or Layer-7 processing delays.
DNS Telemetry with systemd-resolved & dig
Modern Linux distributions deploy systemd-resolved as a local caching stub resolver bound to 127.0.0.53:53.
# 1. Inspect configured upstream DNS servers, domain search paths, and link bindings
resolvectl status
# 2. Query a domain explicitly through systemd-resolved
resolvectl query nejat-hakan.de
# 3. Purge the local resolver cache completely
sudo resolvectl flush-caches
# 1. Unadorned query targeting an authoritative nameserver directly
dig @1.1.1.1 nejat-hakan.de A +noall +answer
# 2. Iterative trace of DNS delegation from root (.) down to authoritative zone
dig +trace +nodnssec nejat-hakan.de A
# 3. Reverse DNS lookup (query PTR record for an IP address)
dig -x 8.8.8.8 +short
Layer-7 Latency Breakdown with curl -w
Using the -w (Write-Out) parameter, dissect the latency profile of an HTTP/HTTPS transaction into distinct millisecond milestones:
curl -so /dev/null -w "\
DNS Lookup Time: %{time_namelookup}s\n\
TCP Connect Time: %{time_connect}s\n\
TLS Handshake Time: %{time_appconnect}s\n\
Server Processing TTFB: %{time_starttransfer}s\n\
----------------------------------------------\n\
Total Request Time: %{time_total}s (HTTP %{http_code})\n" \
https://nejat-hakan.de
DNS Lookup Time: 0.004120s
TCP Connect Time: 0.018240s
TLS Handshake Time: 0.042180s
Server Processing TTFB: 0.089450s
----------------------------------------------
Total Request Time: 0.092110s (HTTP 200)
time_namelookup > 0.5s: DNS server congestion or misconfigured timeouts in /etc/resolv.conf.
* If time_connect is high: Network RTT latency or packet loss during the TCP 3-way handshake.
* If time_starttransfer (Time-to-First-Byte) is elevated: Network transit is fast, but backend application execution (database queries, rendering pipelines) is stalling response generation.
Raw Socket Swiss Army Knife: netcat & socat
# 1. Test TCP port reachability without transmitting data (2-second timeout)
nc -zv -w 2 192.168.1.100 5432
# 2. Launch an ad-hoc TCP listener to verify firewall rule traversal
nc -l -p 8080
# 3. Port forwarding with socat: Relay incoming port 8080 to a remote database node
sudo socat TCP-LISTEN:8080,fork TCP:internal-database:5432
# 4. Bridge a local UNIX domain socket to a network TCP port
sudo socat TCP-LISTEN:2375,fork,reuseaddr UNIX-CONNECT:/var/run/docker.sock