Course contentsShow
← Security
Lesson 439 of 3,05210. Network Security - Firewalls and SegmentationFree lesson

iptables Actions and Targets

Using ACCEPT, DROP, REJECT, LOG, and custom chains to control packet disposition and create modular rulesets.

iptables Actions and Targets

You'll learn: How to tell iptables what to do with packets that match your rules using targets like ACCEPT, DROP, REJECT, LOG, and custom chains.

What Are Targets?

When a packet matches an iptables rule (as you learned in rule syntax), the rule must specify what happens next—that's the target. Think of it like a sorting conveyor belt: when a package (packet) matches certain criteria, you need a label telling workers whether to accept it, toss it out, send it elsewhere, or write down what happened.

The target is specified with the -j (jump) flag in your iptables command.

Core Built-In Targets

ACCEPT

Allows the packet through—it passes this checkpoint and continues its journey through the network stack.

DROP

Silently discards the packet. The sender gets no notification, just... silence. Useful for blocking without revealing your firewall's presence.

REJECT

Refuses the packet and sends an error message back to the sender (like "connection refused"). More polite than DROP but reveals your firewall exists.

LOG

Records packet details to system logs without stopping the packet. The packet continues to the next rule. Perfect for troubleshooting or security monitoring—you can see what's happening without blocking traffic.

Custom Chains

You can create your own chains as targets, building modular rulesets. Jump to a custom chain to apply a group of specialized rules, then return to the main chain. This keeps complex firewall configurations organized and maintainable—like subroutines in programming.

Key Takeaway: iptables targets (ACCEPT, DROP, REJECT, LOG) determine packet fate when rules match; custom chains let you build organized, reusable rule modules that make complex firewalls manageable.