fwgen is a Linux iptables firewall rule generator. It takes a high-level description of the firewall rules and geneates the necessary iptables commands to implement those rules.
fwgen is licenced under the GNU General Public Licence (GPL).
The latest version is available in source form here:
Debian packages are available in my PPA:
Source and binary RPMs are available here:
Older releases are available in the archive (source only).
Do one of the following:
Read the man page and the README file for details of how to write an input file for fwgen.
Generate your rules by running fwgen.
Run the generated shell script before bringing up your network interfaces, for example, by using the pre-up directive in /etc/network/interfaces on a Debian/Ubuntu system.
See the README file and man page included in the fwgen package.