How to list the iptables rules in a customized way? Like:

target protocol portnumber src dest

the order could be changed but I dont want the name of protocols, just number (like 80 instead of http)

Can anybody tell me how to do that?


iptables does not support a generic --output-format option or similar, but if all you want is to have numbers instead of names, use the -n option. From man iptables:

-n, --numeric
   Numeric  output.   IP  addresses  and  port  numbers  will be
   printed in numeric format.  By default, the program will  try
   to  display  them  as  host names, network names, or services
   (whenever applicable).

If you want to do something fancy, you're on your own - I'd suggest you start by running iptables-save and pipe the result to awk or something like that.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.