I have an iptables rule and I have to write a script that gets the numbers of packets and bytes target for that rule. I know that that command iptables -L -v -x shows that info, but I don't know how to extract it with a script.

It will be just a single rule in forward chain. Can somebody help me with this script? I have to show the answer on the console.

link|improve this question
feedback

1 Answer

You can simply redirect the answer in a file, like this

# iptables -L -v -x >> ~/iptable-stats.txt

Then, you can extract the right argument easier as it was shown on the prompt.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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