Diving deeper with iptables
While UFW is great for firewall management, iptables provides granular control over network traffic. In fact, UFW is a tool that simplifies the configuration of the kernel’s package filter, iptables. It filters packets using chains (INPUT, OUTPUT, FORWARD) and rules.

Figure 12.1 – iptables
Here is the basic iptables structure:
- Tables: Contain chains related to specific functions (for example, filter table for general packet filtering).
- Chains: Contain rules that are applied sequentially to packets.
- Rules: Define criteria for matching packets and actions to take (
ACCEPT,DROP,REJECT).
For example, this code blocks traffic from a specific IP address:
ken@monster:~$ sudo iptables -A INPUT -s 192.168.1.100 -j DROP
This command appends (-A) a rule to the INPUT chain that drops (-j DROP) all packets from the source (-s) IP address 192.168.1.100.