In the iptables man file there is an option
S, --list-rules [chain]
Print all rules in the selected chain. If no chain is selected, all chains are printed like iptables-save. Like every other iptables
command, it applies to the specified table (filter is the default).
iptables -S | grep <CHAINNAMEHERE>. For examples:
root@root:~# iptables -S | grep TRAFFICLOG
-A FORWARD -i eth0 -j TRAFFICLOG
you can then see which rules are blocking the deletion of the chain from the table. Go through each rule (except the
iptables -N <CHAINNAMEHERE> and delete the rule by using the
-D, --delete chain rulenum
Delete one or more rules from the selected chain. There are two versions of this command: the rule can be specified as a number in the
chain (starting at 1 for the first rule) or a rule to match.
iptables -D FORWARD -i eth0 -j TRAFFICLOG. After you have deleted each rule for your chain flush the chain with the
iptables -F <CHAINNAMEHERE>.
-F, --flush [chain]
Flush the selected chain (all the chains in the table if none is given). This is equivalent to deleting all the rules one by one.
Then delete your chain with the
iptables -X <CHAINNAMEHERE>
-X, --delete-chain [chain]
Delete the optional user-defined chain specified. There must be no references to the chain. If there are, you must delete or replace
the referring rules before the chain can be deleted. The chain must be empty, i.e. not contain any rules. If no argument is given, it
will attempt to delete every non-builtin chain in the table.
Iptables is a complicated tool set so an ideal tutorial is needed. You can try one out at www.iptables.info