$linuxjunkies
>

conntrack(8)

conntrack is a userspace tool for querying and managing netfilter connection tracking state.

UbuntuDebianFedoraArch

Synopsis

conntrack [options] [commands]

Description

conntrack provides userspace access to the netfilter connection tracking subsystem, allowing you to query, update, and delete connection tracking entries. It is essential for managing stateful firewall rules, NAT operations, and network debugging on Linux systems using netfilter/iptables.

The tool can display active connections, show statistics, configure timeout values, and manage conntrack events in real-time. It's commonly used for network troubleshooting, monitoring active connections, and tuning firewall behavior.

Common options

FlagWhat it does
-L, --dumpList all tracked connections in the conntrack table
-E, --eventShow conntrack events in real-time (new, update, destroy)
-S, --statsShow conntrack statistics and memory usage information
-D, --deleteDelete connections matching specified criteria
-U, --updateUpdate properties of an existing conntrack entry
-I, --createCreate a new conntrack entry manually
-p, --protonumFilter by protocol (tcp, udp, icmp, etc.)
-s, --srcFilter by source IP address
-d, --dstFilter by destination IP address
--sportFilter by source port number
--dportFilter by destination port number
-o, --outputSelect output format (xml, extended, compact)

Examples

List all active connections currently tracked by netfilter

conntrack -L

List only TCP connections in the conntrack table

conntrack -L -p tcp

Show all connections originating from 192.168.1.100

conntrack -L -s 192.168.1.100

Monitor conntrack events in real-time as connections are created and destroyed

conntrack -E

Display overall conntrack statistics including number of entries and memory usage

conntrack -S

Delete all tracked TCP connections using destination port 22 (SSH)

conntrack -D -p tcp --dport 22

List only established TCP connections

conntrack -L -p tcp --state ESTABLISHED

Display connections in extended format with additional details

conntrack -L -o extended

Related commands