How to remove Iptable rule in Linux

[ERROR] Unable to find command: C:\Program Files\nodejs\node. exe
September 6, 2018
How to Integrate Google+ authentication in Ionic V1
September 7, 2018

How to remove Iptable rule in Linux

In Linux, Iptables is a security wall of the system. In this you will learn how to delete the Iptable rules in Linux system.

The easiest way to delete the rule is by chain and number. Follow this command to remove existing rules.

  • Type this command to show rules by number
$ sudo iptables -L --line-numbers 
  • This command show all the rules form Iptables.

[secondary_output Example Output: Rules with Line Numbers]
Chain INPUT (policy DROP) num  target     prot opt source               destination 
1    ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED 
2    ACCEPT     all  --  anywhere             anywhere 
3    DROP       all  --  anywhere             anywhere             ctstate INVALID 
  • Now check rule number and select which one you want to remove
  • Use following command iptables -D for remove a rule.
 sudo iptables -D INPUT 2 
  • Rule will be deleted form Iptables.

Leave a Reply