iptables Stateful Firewall Rules
Restrict a service port to internal traffic only without locking yourself out of SSH.
A advanced Linux challenge worth 20 points. Solve it hands-on in a real Linux environment in your browser - no local setup, no fake shells.
The Challenge
A microservice must accept port 8080 only from 10.0.0.0/8. All other traffic to 8080 must be dropped. One attacker IP must be blocked entirely.
Your tasks:
- Write the correct iptables rules to /etc/iptables/rules.v4:
Block attacker IP 203.0.113.42 entirely (INPUT chain, -j DROP) ACCEPT ESTABLISHED,RELATED (protects SSH) ACCEPT port 8080 from 10.0.0.0/8 DROP port 8080 from all other sources
- Format: one rule per line in iptables-save format
- Apply if iptables is available: iptables-restore < /etc/iptables/rules.v4 2>/dev/null || true
- Run check to validate