Setting Up UFW Firewall

Learn how to set up and manage UFW (Uncomplicated Firewall) on Ubuntu with advanced configurations.

  1. Install UFW:
sudo apt install ufw
  1. Set default policies:
sudo ufw default deny incoming
sudo ufw default allow outgoing
  1. Enable UFW:
sudo ufw enable
  1. Allow specific services:
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
  1. Advanced configurations:
# Allow specific IP range
sudo ufw allow from 192.168.1.0/24

# Rate limiting
sudo ufw limit ssh

# Delete rule
sudo ufw delete allow http

Monitoring and logging:

  • Check status: sudo ufw status verbose
  • View logs: sudo less /var/log/ufw.log
  • Monitor real-time: sudo ufw logging on

Read more: UFW Documentation