Thursday, July 27, 2023

Delete iptables rule using line number

To easiest way to delete iptables rules, is by listing the rule with line number like below

$ sudo iptables -L OUTPUT --line-number

In this example, we are listing all the rules inside OUTPUT chain, with line number





To delete that rule, use this command
$ sudo iptables -D OUTPUT 1

like below




We can run the first command to verify that the rule has been deleted
$ sudo iptables -L OUTPUT --line-number

like below





To delete multiple rules, just repeat the same steps over and over again.

No comments: