I need to add a rule to iptables to block connections to a tcp port from the Internet.
Since my script may be called multiple times and there is not a script to delete the rule, I want to check if an iptables rule already exists before inserting it - otherwise there will be a lot of dup rules in the INPUT chain.
How can I check if an iptables rule already exists?