· 7 min read

nf_conntrack Table Full: Fix Dropped Packets in DDoS

The "nf_conntrack: table full, dropping packet" error means the Linux connection tracking table has hit nf_conntrack_max, so the kernel drops every packet that would need a new entry. To fix it, confirm what is filling the table, raise the limit and hash size within your memory budget, shorten timeouts for half-open flows, and exclude stateless traffic with NOTRACK rules in the raw table.

Be realistic about what this achieves. Conntrack tuning raises the floor for small and medium floods. It does not stop an attack that saturates your uplink or your CPU's softirq capacity. Once the host is the bottleneck, you need detection and mitigation upstream.

What the error actually means

Netfilter creates a conntrack entry for each new flow that crosses a hook where tracking is active. This includes INPUT, FORWARD, NAT and any host using -m conntrack or -m state rules. Under a flood, two things happen:

The log line appears in dmesg or /var/log/kern.log. Legitimate users see timeouts, even if the link is not full.

Step 1: Diagnose what is filling the table

Check current usage against the limit:

sysctl net.netfilter.nf_conntrack_count net.netfilter.nf_conntrack_max
sysctl net.netfilter.nf_conntrack_buckets
conntrack -C

Check the drop counters. Rising drop, insert_failed or early_drop values confirm table pressure:

conntrack -S | head -n 4

Break the table down by TCP state and by source and destination:

conntrack -L -p tcp 2>/dev/null | awk '{print $4}' | sort | uniq -c | sort -rn

conntrack -L 2>/dev/null | awk '{for(i=1;i<=NF;i++) if($i ~ /^src=/){print $i; break}}' \
  | sort | uniq -c | sort -rn | head

conntrack -L 2>/dev/null | awk '{for(i=1;i<=NF;i++) if($i ~ /^dst=/){print $i; break}}' \
  | sort | uniq -c | sort -rn | head

How to read the output:

Observation Likely cause
Mostly SYN_SENT / SYN_RECV SYN flood
Mostly UDP, huge number of unique sources UDP flood with spoofed or random sources
One destination dominates Attack on a single IP (RTBH or FlowSpec candidate)
Mostly ESTABLISHED, few sources Connection exhaustion or a misbehaving client, not a spoofed flood

Also check whether the NIC or CPU is the real limit:

nstat -az | grep -Ei 'drop|overflow'
cat /proc/net/softnet_stat
ethtool -S eth0 | grep -Ei 'drop|miss|fifo'

If softnet drops or NIC rx_missed counters climb while conntrack is healthy, no sysctl will help.

Step 2: Raise the limit and hash size safely

Each entry costs memory, typically a few hundred bytes. Check actual usage with slabtop (the nf_conntrack cache) rather than guessing. Budget memory first, then set the values. For example, 2,000,000 entries at roughly 300 to 350 bytes each is on the order of 600 to 700 MB.

Keep the hash table proportional to the maximum. A long average chain per bucket increases lookup cost, and that costs CPU during a flood. A ratio of about 4 entries per bucket or lower is a sensible target. Check your kernel's default ratio before changing it.

Runtime changes:

sysctl -w net.netfilter.nf_conntrack_max=2097152
echo 524288 > /sys/module/nf_conntrack/parameters/hashsize

Persist them:

# /etc/sysctl.d/90-conntrack.conf
net.netfilter.nf_conntrack_max = 2097152

# /etc/modprobe.d/nf_conntrack.conf
options nf_conntrack hashsize=524288

Note that nf_conntrack_buckets is read-only through sysctl. Use the module parameter. Containers and network namespaces may have separate counters, so check inside the namespace that handles the traffic.

Step 3: Shorten timeouts for half-open and short-lived flows

Default timeouts assume a clean network. Defaults include 120 seconds for syn_sent, 60 for syn_recv, 30 for udp, and 432000 (five days) for established TCP. Reasonable starting points for an internet-facing server:

# /etc/sysctl.d/90-conntrack.conf
net.netfilter.nf_conntrack_tcp_timeout_syn_sent = 20
net.netfilter.nf_conntrack_tcp_timeout_syn_recv = 20
net.netfilter.nf_conntrack_tcp_timeout_established = 3600
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 30
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 15
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 30
net.netfilter.nf_conntrack_udp_timeout = 10
net.netfilter.nf_conntrack_udp_timeout_stream = 60
net.netfilter.nf_conntrack_tcp_loose = 0

Common mistakes with these values:

The MikroTik equivalent, if the box in question is a router or CHR in the path:

/ip firewall connection tracking set tcp-syn-sent-timeout=10s tcp-syn-received-timeout=10s udp-timeout=10s

Step 4: Use NOTRACK and raw table rules

The best conntrack entry is the one never created. Packets matched in the raw table, which runs before conntrack, are not tracked at all. Two uses:

  1. Skip tracking for stateless services. Examples are authoritative DNS, NTP, or a game server on a fixed UDP port.
  2. Drop known-bad traffic before it costs an entry. Examples are UDP to ports you don't serve, or source ranges you've already identified.

iptables:

# Don't track DNS on 192.0.2.10
iptables -t raw -A PREROUTING -d 192.0.2.10 -p udp --dport 53 -j CT --notrack
iptables -t raw -A OUTPUT     -s 192.0.2.10 -p udp --sport 53 -j CT --notrack

# Accept untracked DNS in the filter table
iptables -A INPUT -d 192.0.2.10 -p udp --dport 53 -m conntrack --ctstate UNTRACKED -j ACCEPT

# Drop UDP to unused ports before conntrack sees it
iptables -t raw -A PREROUTING -d 192.0.2.10 -p udp -m multiport ! --dports 53,123 -j DROP

nftables:

table inet raw {
  chain prerouting {
    type filter hook prerouting priority raw; policy accept;
    ip daddr 192.0.2.10 udp dport 53 notrack
    ip daddr 192.0.2.10 udp dport != { 53, 123 } drop
  }
  chain output {
    type filter hook output priority raw; policy accept;
    ip saddr 192.0.2.10 udp sport 53 notrack
  }
}

Caveats:

Step 5: Know when the host has already lost

Suppose you have raised the limits, shortened timeouts, and NOTRACKed what you can. A flood can still win:

At that point, mitigation must happen at the network edge. The usual escalation:

  1. Detect from flows. NetFlow, IPFIX or sFlow from your edge routers show the victim IP and the attack type within seconds. Host-side counters tell you much later.
  2. RTBH as a last resort for a single victim IP. On Juniper, for example (provider communities vary; 65535:666 is the standard from RFC 7999):
set routing-options static route 192.0.2.10/32 discard community 65535:666

This protects the rest of your network but takes the victim offline. See our guide to automating RTBH for the details.

  1. BGP FlowSpec to drop or rate-limit just the attack signature, such as a UDP source port or SYN packets above a rate, while legitimate traffic still flows.
  2. Scrubbing for attacks that blackholing would turn into a full outage. This applies when the target must stay reachable.

Where NixMon fits

NixMon analyzes NetFlow v5/v9, IPFIX and sFlow with sub-second traffic analytics. You set per-IP and per-prefix bps and pps thresholds. When one is crossed, it can announce a BGP blackhole or a FlowSpec rule, or trigger an on-prem NixGuard firewall. That gets the flood off the server before conntrack matters.

If you operate your own ASN with at least one /24, NixGuard Edge is a cloud scrubbing option. Your prefixes are announced from the scrubbing edge, and clean traffic returns over a GRE tunnel with a BGP session inside. It can run always-on or on-demand. You can try detection with a 15-day free trial, with no credit card.

Checklist

Frequently asked questions

What does 'nf_conntrack: table full, dropping packet' mean?

The conntrack table has reached nf_conntrack_max, so the kernel drops packets that would need a new entry. During SYN or UDP floods this happens quickly because each spoofed packet or new source tuple creates an entry.

How high should I set nf_conntrack_max?

Set it based on memory, not on a fixed number. Each entry uses a few hundred bytes, so check the nf_conntrack slab with slabtop and leave headroom for the rest of the system. Scale the hash size with it, and keep entries per bucket low.

Is it safe to use NOTRACK on a server?

Yes for stateless services such as DNS or NTP, if you add explicit filter rules that accept the UNTRACKED state. Untracked traffic cannot be NATed and does not match ESTABLISHED rules, so test before production.

Will conntrack tuning stop a DDoS attack?

No. It helps the host survive small and medium floods. If the attack fills the uplink or exhausts CPU in the receive path, you need upstream mitigation: RTBH, FlowSpec or scrubbing, triggered by flow-based detection.

Detect floods before conntrack fills. Start your 15-day free trial.Learn more