What are common UFW commands?

QuestionsQuestions8 SkillsProEnabling Basic FirewallNov, 25 2025
0156

Here are some common UFW (Uncomplicated Firewall) commands that you can use to manage firewall rules effectively:

Basic Commands

  1. Enable UFW:

    sudo ufw enable

    Activates the firewall with the current rules.

  2. Disable UFW:

    sudo ufw disable

    Deactivates the firewall.

  3. Check Status:

    sudo ufw status

    Displays the current status of UFW and the rules in effect.

  4. Verbose Status:

    sudo ufw status verbose

    Provides detailed information about the current rules and policies.

Managing Rules

  1. Allow Incoming Traffic:

    sudo ufw allow <port>

    Example: Allow HTTP traffic on port 80:

    sudo ufw allow 80
  2. Deny Incoming Traffic:

    sudo ufw deny <port>

    Example: Deny traffic on port 23 (Telnet):

    sudo ufw deny 23
  3. Allow Specific Service:

    sudo ufw allow <service>

    Example: Allow SSH:

    sudo ufw allow ssh
  4. Delete a Rule:

    sudo ufw delete allow <port>

    Example: Remove the rule allowing HTTP:

    sudo ufw delete allow 80

Advanced Commands

  1. Allow Traffic from a Specific IP:

    sudo ufw allow from <IP_address>

    Example: Allow traffic from a specific IP:

    sudo ufw allow from 192.168.1.100
  2. Deny Traffic from a Specific IP:

    sudo ufw deny from <IP_address>
  3. Logging:

    sudo ufw logging on

    Enables logging of firewall events.

  4. Reset UFW:

    sudo ufw reset

    Resets UFW to its default state, removing all rules.

Example Usage

To set up a basic web server, you might run:

sudo ufw allow ssh
sudo ufw allow 80
sudo ufw enable

This configuration allows SSH access and HTTP traffic while keeping other ports closed.

Feel free to ask if you have any questions or need further clarification on any command!

0 Comments

no data
Be the first to share your comment!