iptables show just one chain

tldr: How can I get iptables to show just one chain?

I can have iptables show just one table, but a table consists of multiple chains. I need to find where in chain INPUT is the last rule (usually but not always the REJECT all rule).

I've tried awk and even some grep, but my skill in those must be waning. I've tried using awk to get just one paragraph, but that doesn't seem to work on the output of iptables --line-numbers -n -L -t filter maybe because those blank lines aren't really blank.

I am looking for a solution with any normal gnu tools that would be installed on a CentOS 6 minimal environment.


Solution 1:

I almost deleted this question. D'oh! From man iptables:

   -L, --list [chain]
          List  all rules in the selected chain.

Solution 2:

For those who might want to look at the mangle or nat tables with chains you can do so like

iptables -L mychainname -t mangle

Then it will show you that chain in the mangle table.