it seems much like you are getting lacked with some modules, rather than a well scripted firewall script. You need to test with lsmod and be sure that you have modules loaded for the iptables flags and chains. Just take a look at these modules which I have loaded below and relevant for iptables:
According to me, You're not loading one or more of them. Just check it out and install the rest of the modules.