Miscellaneous notes on IPTables.
I've seen iptables described in a number of different manners, but none of them quite manage to encapsulate all of the aspects in one go, so I often end up drawing a diagram on paper based on the three main different use-cases. These are :-
There are three different types of rule. These are the "tables" in the name iptables :-
There are five different positions that these rule types can be found in :-
The positions are called "chains":
table | chains |
filter | INPUT FORWARD OUTPUT |
nat | PREROUTING POSTROUTING OUTPUT |
mangle | PREROUTING INPUT FORWARD OUTPUT POSTROUTING |
A chain is a list of rules. Each rule has a condition and an action:
condition | action |
When a packet enters a chain, it is tested against each rule in turn. The action of a rule is carried out if the condition is met. Some actions cause the packet to leave the chain immediately, skipping untested rules. The actions are called TARGETS. Some popular targets are:
When you configure your firewall, you build this list of rules using the iptables tool.
The state diagram looks like this (using the GraphViz? plugin) :-
One page links to IptablesNotes:
lib/WikiPluginCached.php (In template 'html'):534: Notice: Use of undefined constant IMG_PNG - assumed 'IMG_PNG' (...repeated 4 times)
lib/pear/Cache/Container/file.php (In template 'html'):339: Warning: mkdir(/tmp/cache/imagecache/) [<a href='function.mkdir'>function.mkdir</a>]: Permission denied
lib/WikiPluginCached.php (In template 'html'):535: Notice: Use of undefined constant IMG_GIF - assumed 'IMG_GIF'
lib/WikiPluginCached.php (In template 'html'):536: Notice: Use of undefined constant IMG_JPEG - assumed 'IMG_JPEG'
lib/plugin/GraphViz.php (In template 'html'):234: Warning: fopen() expects parameter 1 to be string, array given