Lab 4: Firewall Configuration using ufw
Objective:
- To understand and practice firewall configuration on a Linux system.
Topics Covered:
- Introduction to Firewalls
- Installing and Enabling
ufw
(Uncomplicated Firewall) - Basic
ufw
Commands - Configuring Firewall Rules
- Advanced Firewall Configuration
Lab Exercises:
Exercise 1: Introduction to Firewalls
- Understand purpose of a firewall in a Linux system.
- Understand the concept of incoming and outgoing traffic.
- Learn the basic principles of stateful and stateless firewalls.
Exercise 2: Installing and Enabling ufw
# Install `ufw` if not already installed
sudo apt-get install ufw
# Enable `ufw`
sudo ufw enable
Exercise 3: Basic ufw
Commands
# Check the status of `ufw`
sudo ufw status
# Disable `ufw`
sudo ufw disable
# Reset `ufw` rules
sudo ufw reset
Exercise 4: Configuring Firewall Rules
# Allow incoming SSH connections
sudo ufw allow 22/tcp
# Allow incoming connections on a custom service/port (e.g., web server)
sudo ufw allow 80/tcp
# Deny incoming connections on a specific port
sudo ufw deny 1234/tcp
Exercise 5: Advanced Firewall Configuration
# Check the list of applications with `ufw` profiles
sudo ufw app list
# Allow traffic for a specific application profile (e.g., OpenSSH)
sudo ufw allow OpenSSH
# Limit the rate of incoming connections from an IP address
sudo ufw limit from <IP_address> to any port 22
# Create a custom rule for a specific IP range
sudo ufw allow from 192.168.1.0/24
# Delete a rule by number
sudo ufw delete <rule_number>
Lab Documentation:
Provide detailed instructions for each exercise, including command syntax and expected outcomes. Include explanations of the purpose behind each task.