How can I delete a specific rule in iptables on Linux?
You can remove a rule in Linux using the iptables command. Here are the steps to delete a rule using the iptables command:
- First, list the current iptables rules using the following command:
sudo iptables -L
- Find the rule to be deleted in the list of rules, make note of the rule’s number or other identifier.
- Replace
with the number or identifier of the rule you want to delete when using the following command to remove a rule.
sudo iptables -D <rule_number>
- List the iptables rules again using the following command to ensure that the rules have been successfully deleted:
sudo iptables -L
Please note that root or sudo privileges are required to delete rules.