2.17. Deleting Firewall Rules
Problem
You want to delete firewall rules, individually or all at once.
Solution
To delete rules en masse, also called flushing a chain, do the following:
For iptables
:
# iptables -F [chain
]
For ipchains
:
# ipchains -F [chain
]
To delete rules individually:
For iptables
:
# iptables -Dchain
rule_number
For ipchains
:
# ipchains -Dchain
rule_number
Discussion
Rules are numbered beginning with 1. To list the rules:
# iptables -L # ipchains -L
select one to delete (say, rule 4 on the input chain), and type:
# iptables -D INPUT 4 # ipchains -D input 4
If you’ve previously saved your rules and want your deletions to remain in effect after the next reboot, re-save the new configuration. [Recipe 2.19]
See Also
iptables(8), ipchains(8).
Get Linux Security Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.