Back to course

75. Introduction to Firewalls (`ufw`)

Linux Basics: From Zero to CLI Hero

Controlling Network Traffic

A firewall controls incoming and outgoing network traffic based on predefined security rules. Ubuntu uses ufw (Uncomplicated Firewall) as its front-end for managing the powerful netfilter kernel module.

ufw Status

Check if the firewall is active:

bash $ sudo ufw status verbose Status: inactive

Essential Actions

  1. Enabling the Firewall: bash $ sudo ufw enable

  2. Setting Default Policy: Deny all incoming connections (best practice). bash $ sudo ufw default deny incoming

  3. Allowing Specific Traffic (by Port): bash

    Allow SSH connections on default port 22

    $ sudo ufw allow 22

    Allow HTTP traffic

    $ sudo ufw allow http

  4. Deleting Rules: bash $ sudo ufw delete allow 80