V
V
Valery Ivanov2015-01-25 23:22:23
linux
Valery Ivanov, 2015-01-25 23:22:23

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

2 answer(s)
A
Archie Kuznetsov, 2015-01-26
@Wolf4ara

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 */

or
[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

(The output may differ, but it will be approximately the same). The first digit is the line number. Now it just needs to be removed (line):
sudo iptables -D INPUT 10

R
Roman Bazalevsky, 2015-01-26
@rvbglas

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 question

Ask a Question

731 491 924 answers to any question