Answer the question
In order to leave comments, you need to log in
How to properly delete a rule in iptables?
Hello! Please just reply me with command how to remove all rules for port 80?
For example, I will create a rule for port 80 to block one IP, then the second.
Then I decide to delete all rules for port 80, how to do it?
Answer the question
In order to leave comments, you need to log in
Good afternoon! As I understand it, you are not familiar with iptables. Then do it like this:
[email protected]:~:26/01/15-08:57$ sudo iptables -L -nv --line-numbers | grep "dports 80"
10 46M 8605M ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp multiport dports 80,443 /* WEB */
[email protected]:~:26/01/15-08:57$ sudo iptables -L -nv | grep "dport 80"
10 46M 8605M ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dport 80
sudo iptables -D INPUT 10
Only in the case of deletion by number, one should not forget that when one rule is deleted, the numbering of the subsequent ones creeps. Those. if you delete several - it's easier from the last number to the first, less likely to screw up.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question