Scroll to navigation



iptstate - A top-like display of IP Tables state table entries


iptstate [<options>]


iptstate displays information held in the IP Tables state table in real-time in a top-like format. Output can be sorted by any field, or any field reversed. Users can choose to have the output only print once and exit, rather than the top-like system. Refresh rate is configurable, IPs can be resolved to names, output can be formatted, the display can be filtered, and color coding are among some of the many features.


Toggle color-code by protocol
Toggle display of bytes/packets counters
Only show states with a destination of IP and with optional NETMASK.
Note, that this must be an IP, hostname matching is not yet supported.
Only show states with a destination port of port
Show help message
Invert filters to display non-matching results
Show hostnames instead of IP addresses. Enabling this will also enable -L to prevent an ever-growing number of DNS requests.
Mark truncated hostnames with a '+'
Toggle dynamic formatting
Skip outgoing DNS lookup states
Filter states on loopback
No scrolling (don't use a "pad"). See SCROLLING AND PADS for more information.
Reverse sort order
Refresh rate, followed by rate in seconds. Note that this is for statetop mode, and not applicable for single-run mode (--single).
-1, --single
Single run (no curses)
This determines what column to sort by. Options:
S Source Port
d Destination IP (or Name)
D Destination Port
p Protocol
s State
b Bytes
P Packets
To sort by Source IP (or Name), don't use -b. Sorting by bytes/packets is only available for kernels that support it, and only when compiled against libnetfilter_conntrack (the default).
Only show states with a source of IP and with optional NETMASK.
Note, that this must be an IP, hostname matching is not yet supported.
Only show states with a source port of port
Toggle display of totals


As of version 2.0, all command-line options are now available interactively using the same key as the short-option. For example, --sort is also -b, so while iptstate is running, hitting b will change the sorting to the next column. Similarly, t toggles the display of totals, and so on.

There are also extra interactive options: B - change sorting to previous column (opposite of b); q - quit; and x - delete the currently highlighted state from the netfilter conntrack table.

Additionally, the following keys are used to navigate within iptstate:

In many cases, iptstate needs to prompt you in order to change something. For example, if you want to set or change the source-ip filter, when you hit s, iptstate will pop up a prompt at the top of the window to ask you what you want to set it to.

Note that like many UNIX applications, ctrl-G will tell iptstate "nevermind" - it'll remove the prompt and forget you ever hit s.

In most cases, a blank response means "clear" - clear the source IP filter, for example.

At anytime while iptstate is running, you can hit h to get to the interactive help which will display all the current settings to you as well give you a list of all interactive commands available.

While running, space will immediately update the display. Iptstate should gracefully handle all window resizes, but if it doesn't, you can force it to re-calculate and re-draw the screen with a ctrl-L.

Note that hitting l to enable hostname resolution while in interactive mode will also enable L to skip all DNS entries (to prevent an ever-growing number of DNS requests).


For almost any user, there is no reason to turn off scrolling. The ability to turn this off - and especially the ability to toggle this interactively - is done more for theoretical completeness than anything else.


Anything other than 0 indicates and error. A list of current exit statuses are below:

Bad command-line arguments
Error communicating with the netfilter subsystem.
Terminal too narrow


We don't support filtering on resolved names. IPv6 support is new and the dynamic formatting doesn't yet always handle IPv6 addresses as well as it should.


All bugs should be reported to Phil Dibowitz <phil AT ipom DOT com>. Please see the README and BUGS for more information on bug reports. Please read the WISHLIST before sending in features you hope to see.


iptstate does a lot of work to try to fit everything on the screen in an easy-to-read way. However, in some cases, hostnames may need to be truncated (in lookup mode). Similarly, IPv6 addresses may need to be truncated. The truncation of names happens from the right for source because you most likely know your own domain name, and from the left for destination because knowing your users are connection to "mail.a." doesn't help much. However, for addresses, this is reversed.

iptstate does not automatically handle window-resizes while in the interactive help screen. If you do resize while in this window, you should return to the main window, hit ctrl-L to re-calculate and re-draw the screen, and then, if you choose, return to the interactive help.

iptstate currently uses libnetfilter_conntrack to access the netfilter connection state table. However, older versions read out of /proc/net/ip_conntrack, and the current version can still be compiled to do this. This deprecated method can be racy on SMP systems, and can hurt performance on very heavily loaded firewalls. This deprecated method should be avoided - support will be removed in future versions.




iptstate was written by Phil Dibowitz <phil AT ipom DOT com>

JUNE 2012