Configure iptables and ufw rules to allow and deny traffic based on security scenarios
| Chain | Direction | Purpose |
|---|---|---|
| INPUT | Inbound | Traffic destined for this host |
| OUTPUT | Outbound | Traffic originating from this host |
| FORWARD | Through | Traffic passing through (routing/NAT) |
| Action | Behavior |
|---|---|
| ACCEPT | Allow the packet through |
| DROP | Silently discard the packet |
| REJECT | Discard and send error response back |
| LOG | Log the packet then continue processing |
You are securing a web server (10.50.25.100). The security policy requires:
| Task | iptables | ufw |
|---|---|---|
| Allow SSH | iptables -A INPUT -p tcp --dport 22 -j ACCEPT | ufw allow ssh |
| Allow HTTP | iptables -A INPUT -p tcp --dport 80 -j ACCEPT | ufw allow 80/tcp |
| Allow from subnet | iptables -A INPUT -s 10.0.0.0/24 -j ACCEPT | ufw allow from 10.0.0.0/24 |
| Deny port | iptables -A INPUT -p tcp --dport 23 -j DROP | ufw deny 23/tcp |
| Default deny | iptables -P INPUT DROP | ufw default deny incoming |
| View rules | iptables -L -n -v | ufw status verbose |
For each traffic scenario, select whether it will be ALLOWED or BLOCKED by the ruleset above.