Cybersecurity — Firewalls
Types of firewalls
- Packet filtering: Basic traffic rules
- Stateful: Track connection states
- Application: Deep packet inspection
- Next-gen: Advanced threat prevention
iptables
# Allow HTTP
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# Allow SSH
iptables -A INPUT -p tcp --dport 22 -s 192.168.1.0/24 -j ACCEPT
# Block all
iptables -P INPUT DROP
UFW (Ubuntu)
# Enable
sudo ufw enable
# Allow services
sudo ufw allow ssh
sudo ufw allow 80/tcp
# Status
sudo ufw status verbose
Firewall rules
# Rule structure
rules = [
{'action': 'ALLOW', 'port': 22, 'protocol': 'tcp'},
{'action': 'ALLOW', 'port': 80, 'protocol': 'tcp'},
{'action': 'ALLOW', 'port': 443, 'protocol': 'tcp'},
{'action': 'DENY', 'port': '*', 'protocol': '*'}
]
Best practices
- Default deny policy
- Allow only necessary ports
- Log denied traffic
- Regular rule review
Mini Practice
- Configure iptables
- Set up UFW
- Create firewall rules
- Test rule effectiveness
Up Next
Continue with IDS/IPS - Intrusion detection.
Related Topics
Frequently Asked Questions about Firewalls
What is Firewalls in Cybersecurity?
Firewalls is a fundamental concept in Cybersecurity. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Firewalls?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Firewalls.
Why is Firewalls important in Cybersecurity?
Firewalls is essential for Cybersecurity development. Understanding this concept will help you write better code and solve real-world problems more effectively.