Networking
VERIFIED FIXES

Edge Linux router drops long-lived TCP uploads after conntrack table thrash under heavy NAT load

Environment

Environment

Edge router: Debian-based appliance (custom iptables netfilter stack), single public IPv4 WAN, many internal clients NAT'ed to public address, nf_conntrack default hashsize, nf_conntrack_max tuned low by vendor script; large concurrent uploads to cloud over HTTPS from multiple hosts during backup window.

Symptoms

Symptoms

Long-running TCP uploads (SCP/HTTPS multipart PUTs) stall after 20–90s: application shows stalled progress though TCP connection stays ESTABLISHED; smaller requests complete normally. Throughput intermittently drops to near-zero for specific flows and sometimes resumes after 60–120s.

Observations

Observations

dmesg intermittently reports 'nf_conntrack: table full' and 'nf_conntrack: DROP' messages; /proc/sys/net/netfilter/nf_conntrack_count approaches nf_conntrack_max during peaks; conntrack entries show many short-lived entries and frequent hashchain rehash attempts. No obvious interface errors; increasing nf_conntrack_max temporarily reduces frequency of stalls.

Already attempted

Already attempted

Raised nf_conntrack_max to a higher value live (sysctl), disabled some NAT helpers, added more memory to router, temporarily enabled raw table bypass for trusted hosts — stalls reduced but not eliminated under peak load. Router firmware recently reduced default hashsize on boot by vendor script.

Question

Question

What is causing TCP flows to stall mid-upload when conntrack table gets busy, and how can I make long-lived uploads reliable without disabling NAT or dramatically increasing memory usage?

COMMUNITY RESPONSES

Verified community troubleshooting

1 reply
0
williamweb Answer
user
Posted 4w ago • 0 confirmations

Start by checking nf_conntrack usage while the issue happens: cat /proc/sys/net/netfilter/nf_conntrack_count and compare to nf_conntrack_max. If the count nears the max and dmesg shows 'table full', raise nf_conntrack_max and adjust conntrack buckets (nf_conntrack_buckets) so the hash table isn't overloaded. Also tune tcp timeout values so established transfers aren’t evicted prematurely. As a targeted mitigation, NOTRACK long-lived backup hosts via raw table so those flows bypass conntrack. Verify by running an upload and watching /proc/net/nf_conntrack entries and tcpdump to ensure NAT mappings remain. Revert sysctl changes if other services break.

Showing 1 of 1 community responses
AI DIAGNOSTICS

Incident analysis

Updated 4w ago• Trouble ID

Most likely causes

nf_conntrack table exhaustion (nf_conntrack_max too low) causing new NAT state inserts to be dropped and existing flows evicted 92%
Conntrack hashsize misconfigured too small leading to excessive collisions and slow hashchain traversal under load 68%
Vendor startup script or firewall rule periodically shortens conntrack timeouts or forces table rehash causing transient loss of NAT entries 45%

Summary

The kernel conntrack table protects NAT state; when the table is full or heavily resized, state insertions can fail or existing entries can be dropped, which breaks NAT mapping and causes mid-stream stalls even though TCP state on endpoints remains established. Primary causes are under-provisioned nf_conntrack_max/hashsize, aggressive timeouts or hash collisions (hashsize too small), vendor scripts lowering hashsize on reboot, or interaction with conntrack bypass/raw rules that lead to inconsistent state life cycles. Less likely causes: PMTU/ICMP filtering or asymmetric routing, but logs strongly point to conntrack exhaustion.

Suggested Fixes

Diagnostic step 1
Monitor conntrack usage (watch -n1 cat /proc/sys/net/netfilter/nf_conntrack_count and nf_conntrack_max) during the backup window to correlate stalls with exhaustion.
Diagnostic step 2
Increase nf_conntrack_max and re-calculate appropriate hashsize: set nf_conntrack_max to expected entries * 2 and tune net.netfilter.nf_conntrack_buckets (hashsize) to a prime near nf_conntrack_max/4; on Debian set at boot via /etc/sysctl.d and ensure vendor scripts don't override.
Diagnostic step 3
Tune TCP conntrack timeouts for established connections (net.netfilter.nf_conntrack_tcp_timeout_established) to avoid premature eviction for known long uploads; reduce timeouts for ephemeral UDP if needed.

Continue troubleshooting

Matched from the title, description and tags