Skip to content

Instantly share code, notes, and snippets.

@aabouzaid
Last active August 29, 2015 14:18
Show Gist options
  • Save aabouzaid/3e5e5353b2da20cb6107 to your computer and use it in GitHub Desktop.
Save aabouzaid/3e5e5353b2da20cb6107 to your computer and use it in GitHub Desktop.
#! /bin/bash
count_chains_rules () {
awk '$1 == "Chain" { chain_name = $2 }
chain_name != $2 && $0 != "" { chains[chain_name]++ }
END { ORS="";
for (var in chains) {
print var, chains[var]-1", ";
total += chains[var]-1
}
print total
}'
}
/sbin/iptables -n -t filter -L | count_chains_rules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment