Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to write a script which runs a command or a bunch of commands to check if connection tracking is enabled. Or if any connection is being tracked. Basically knowing if any iptables rule is added that would track connections or is tracking connections.

Any suggestions? I have been trying out thing with listing tables with iptables list commands but I think there should be a more straightforward way.

share|improve this question

Is there some reason why conntrack or netstat-nat already do this?

share|improve this answer
conntrack tools doesn't exactly capture my requirement. Let me re-phrase my requirements, If I run a conntrack command conntrack -L -s -d and see zero entries returned, it could be because of two reasons. One is that none of the entries match the query, the other is no configuration enabling connection tracking. So, how do I find that out if no configuration has been applied with a command or a script. I can write the script, just need the idea. Thanks. sorry for being a bit ambiguous. – Gaurav Sinha Dec 13 '11 at 18:10
Can you possibly update your question and elaborate? It is not entirely clear to me what you are asking for. – Zoredache Dec 13 '11 at 18:11
Finally I was able to do it with parsing the command output "iptables -L -t <table>". I checked for hooks that are well defined for the system I work on and it works fine. – Gaurav Sinha Dec 16 '11 at 21:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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