Time to Read

4 minutes

What is UFW (Uncomplicated Firewall)?

UFW stands for Uncomplicated Firewall, and it is a user-friendly command-line interface (CLI) for managing iptables, which is the default firewall management tool for many Linux distributions. UFW is designed to simplify the process of configuring and managing firewall rules, making it more accessible to users who may not be familiar with iptables syntax.

Key features of UFW include:

  1. Simplicity: UFW aims to provide a straightforward and easy-to-use interface for managing firewall rules. The syntax is simpler compared to directly working with iptables commands.
  2. Default Deny Policy: By default, UFW follows a “default deny” policy, meaning that all incoming connections are denied unless there are specific rules allowing them.
  3. Application Profiles: UFW includes predefined application profiles for commonly used services, making it easier to create rules for specific applications without needing to know specific port numbers.
  4. Port Management: UFW allows users to manage firewall rules based on ports, making it simple to open or close access to specific services.
  5. Logging: UFW provides logging options to help users monitor and troubleshoot firewall activities.

Basic UFW Commands:

  1. Enable UFW:

    sudo ufw enable
  

  1. Disable UFW:

    sudo ufw disable
  

  1. Check Firewall Status:

    sudo ufw status
  

  1. Allow Connections on a Specific Port:

    sudo ufw allow [port]
  

  1. Allow Connections on a Specific Port with Protocol:

    sudo ufw allow [port]/[protocol]
  

  1. Allow Access to a Specific Application:

    sudo ufw allow [application]
  

  1. Deny Connections on a Specific Port:

    sudo ufw deny [port]
  

  1. Delete a Rule:

    sudo ufw delete [rule]
  

  1. Reset Rules to Default:

    sudo ufw reset
  

Example Usage:

  • Allow SSH traffic:

    sudo ufw allow ssh
  

  • Allow incoming connections on port 80 (HTTP):

    sudo ufw allow 80
  

  • Deny incoming connections on port 22 (SSH):

    sudo ufw deny 22
  

  • Enable logging:

    sudo ufw logging on
  

  • Reset all rules to default:

    sudo ufw reset
  

UFW provides a higher-level abstraction over iptables, making it suitable for users who want a simpler interface for managing firewall rules on their Linux systems. It is commonly used on Ubuntu and other Debian-based distributions.


Discover more from Sanchit Gurukul

Subscribe to get the latest posts to your email.



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Discover more from Sanchit Gurukul

Subscribe now to keep reading and get access to the full archive.

Continue reading