How can I list two or more particular chains with iptables?

Show a particular chain e.g. DOCKER chain

iptables -L DOCKER

Show all known chains with

iptables -L

Is it possible to show two or more chains with one iptables command?

E.g. show only DOCKER-USER and DOCKER chain, something like this

iptables -L DOCKER,DOCKER-USER or
iptables -L DOCKER DOCKER-USER

but this doesn't work.


I suppose you can write a script for that. I will assume you have bash as your shell.

  1. Create iptables-multilist.sh in $HOME
  2. In iptables-multilist.sh, paste this:
#!/usr/bin/env bash

# you may wish to change "-L" to "-nL" or "-nvL"
COMMAND='iptables -L'
# the delimiter you wish to split on
DELIM=','

IFS=$DELIM
chains=($@)
unset IFS
for chain in ${chains[@]}; do
  $COMMAND $chain
done
  1. Add an alias in $HOME/.bashrc for convenience
alias iptb-L="bash $HOME/iptables-multilist.sh"

After restarting your shell you should be able to just call something like iptb-L INPUT,OUTPUT.