Simplified Firewall lab using UFW
🖥️Firewall Lab
Firewalls are one of the most fundamental components in network security. They act as a protective barrier between your system and the outside world controlling which connections are allowed in or out.
In cybersecurity, understanding how to configure and manage a firewall is an essential skill for defending systems from unauthorized access and attacks.
UFW (Uncomplicated Firewall) is a user-friendly command-line interface for managing firewall rules on Linux systems, particularly those that use iptables underneath (like Ubuntu, Debian, and Kali Linux). It simplifies complex firewall commands into readable and straightforward syntax. With UFW you can quickly implement network protection without needing to memorize intricate iptables rules.
This simplified lab provides a basic hands-on introduction to using UFW to secure a Linux system. You’ll learn how to:
-
Enable and manage UFW
-
Allow or deny traffic on specific ports
-
Set up default policies
-
Test and verify your firewall configuration
Expected output:
Status: inactive
Add Rules
Use UFW to allow or deny specific ports or services:
Purpose | Command | Description |
---|---|---|
Allow SSH | sudo ufw allow 22/tcp | Enables remote login |
Allow HTTP | sudo ufw allow 80/tcp | Enables web traffic |
Allow HTTPS | sudo ufw allow 443/tcp | Enables secure web traffic |
Deny Telnet | sudo ufw deny 23 | Blocks insecure service |
Allow specific IP | sudo ufw allow from 192.168.1.10 | Allows one trusted host |
View Rules
Display active rules:
Sample output:
Delete or Reset Rules
To remove a rule using its number:
To reset all configurations:
Set Default Policies
Define default behavior for all connections:
This ensures your system only accepts allowed traffic while still permitting outbound communication.
Disable UFW
Test the Configuration
You can verify allowed or blocked ports using:
Demonstration:
An important thing to note here is that the UFW firewall goes by the rules descendingly, which means in this case he will allow all traffic before looking into any other rules. Therefore, the deny rule here is ineffective.
Comments