Conntrack: how Linux remembers every network connection
Updated November 1, 2026
The Linux kernel subsystem that remembers every active connection. Without it NAT cannot route a reply back to the right private IP, and a firewall cannot tell a "new connection" from an "already established" one. You see it in /proc/net/nf_conntrack.
Why you need it
When your router does NAT, it rewrites the src IP/port of an outgoing packet. The reply from the server arrives at the router's public IP, and the router must route it back to the correct private IP inside the LAN.
For this to work, the router has to remember every active connection: which internal host, which external one, which ports, which protocol. That memory is conntrack (connection tracking).
Without conntrack:
- NAT would work in one direction only (outgoing yes, reply no way)
- a stateful firewall would be impossible (you cannot tell a "new SYN" from an "already established connection")
What a record holds
Each tracked connection = one record with these fields:
- protocol: TCP/UDP/ICMP/...
- original direction: src IP+port, dst IP+port
- reply direction: the same for the return packet (after NAT)
- state: for TCP,
NEW/ESTABLISHED/RELATED/INVALID - timeout: how much longer it lives with no traffic
See it live:
$ sudo conntrack -L | head
tcp 6 431999 ESTABLISHED src=192.168.1.50 dst=8.8.8.8 \
sport=54321 dport=443 src=8.8.8.8 dst=80.10.20.30 \
sport=443 dport=54321 [ASSURED]Reading it:
tcp 6is TCP, protocol no. 6431999is seconds until timeout (about 5 days for ESTABLISHED)ESTABLISHEDis the state from the TCP state machinesrc=192.168.1.50 ... dst=8.8.8.8is the original directionsrc=8.8.8.8 ... dst=80.10.20.30is the reply direction (notice how dst changed to the public IP, that is the trace of NAT)
States
For TCP:
| State | Meaning |
|---|---|
NEW | Saw the first packet only (SYN) |
ESTABLISHED | Two-way exchange confirmed |
RELATED | Tied to another connection (FTP-data to FTP-control) |
INVALID | Abnormal packet that did not fit anywhere |
These states are the basis for iptables -m state / nft ct state rules. For example, "allow ESTABLISHED+RELATED only" is a standard firewall rule.
Timeouts
Conntrack does not keep a connection forever. There are per-state timeouts:
/proc/sys/net/netfilter/nf_conntrack_tcp_timeout_established = 432000 # 5 days
/proc/sys/net/netfilter/nf_conntrack_tcp_timeout_close_wait = 60 # 1 min
/proc/sys/net/netfilter/nf_conntrack_udp_timeout = 30 # UDPIf a connection closed "dirty" (without FIN), it lingers in conntrack as a zombie for a long time.
Limit and overflow
The conntrack table is bounded (nf_conntrack_max, default about 64K-256K). When it fills up:
- new connections are dropped (or run untracked, depending on the version)
dmesglogsnf_conntrack: table full, dropping packet
On high-traffic servers this is a real problem, so people tune it:
sudo sysctl -w net.netfilter.nf_conntrack_max=1048576When you do NOT need conntrack
- On routers with NAT it is required
- On stateful firewalls it is required
- On a "dumb" router with no NAT and no firewall you can turn it off (with
-j NOTRACKrules) to save CPU and memory. On high-traffic edge routers that is a serious boost
Commands
sudo conntrack -L: All active tracked connectionssudo conntrack -L -p tcp --dport 443: HTTPS connections onlysudo conntrack -E: Realtime events: records created/updated/deletedsudo conntrack -F: Flush the whole table, it rebuilds from live packetscat /proc/sys/net/netfilter/nf_conntrack_count: How many records there are right nowcat /proc/sys/net/netfilter/nf_conntrack_max: The limit. If current approaches it, time to tune