A simple way of building complex firewall rules by writing an abstract ruleset in YAML which will be converted to a BASH script.
Generate the script by the following:
$ php scripts/build.php /path/to/firewall.yml > firewall.sh
A simple example can be found under simple.yml with the resulting script under simple.sh.