The iptables-save file format

General

The iptables-save format is an easy-to-parse representation of an iptables ruleset. Blank lines and those that begin with a # are ignored.

#Comment
*tablename
:BUILTINCHAIN POLICY [packets:bytes]
:USERCHAIN - [0:0]
-A CHAINNAME ...
[packets:bytes] -A CHAINNAME ...
COMMIT

Table

A table definition starts with a * and the table name. It is ended by COMMIT on a line by itself.

Policies

All builtin chains have a default policy, and counters for the packets that match the policy are stored. User-defined chains do not have a policy, and packets that reach the end of the chain will return to the calling chain. The counters are always zero.

Rules

Rules are entered as a commandline to iptables. (Internally, the same code processes them as does iptables arguments). The table argument is omitted, because it is specified at the start of the table definition.

Using iptables-save -c and iptables-restore -c, counters can be specified before the start of each rule.

Last modified Wed Apr 12 11:37:26 2006. ©2005-2007 Daniel De Graaf