Skip to Main Content
Linux Security Cookbook
book

Linux Security Cookbook

by Daniel J. Barrett, Richard E. Silverman, Robert G. Byrnes
June 2003
Intermediate to advanced content levelIntermediate to advanced
336 pages
8h 54m
English
O'Reilly Media, Inc.
Content preview from Linux Security Cookbook

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 -D chain 
               rule_number

For ipchains:

# ipchains -D chain 
               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).

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Administration Cookbook

Linux Administration Cookbook

Adam K. Dean

Publisher Resources

ISBN: 0596003919Errata Page