How to Check the Firewall Status in Ubuntu

The Perimeter Defense Vector

When deploying a new Ubuntu server directly onto the public internet, it is immediately bombarded by automated botnets scanning for open ports and vulnerable services. The operating system contains a built-in cryptographic barrier designed to drop these unauthorized network packets, but this barrier is frequently deactivated by default to ensure you do not accidentally lock yourself out during initial setup. You must interrogate the system architecture to determine the exact operational state of this primary defense mechanism.

How to Check the Firewall Status

Ubuntu relies on the Uncomplicated Firewall (UFW) utility to manage the complex, underlying `iptables` packet filtering rules.

1. Open your terminal application or connect to your server via SSH.
2. The Interrogation Command: Because interrogating the firewall reveals critical security data about open ports, the kernel requires superuser privileges to execute the command.
3. Type the following syntax exactly as written:

sudo ufw status

4. Press Enter. You will be prompted to type your administrative password.
5. Analyzing the Output: The terminal will respond with one of two distinct states.
* State 1: Inactive. The terminal will simply output `Status: inactive`. This means your server is completely exposed to the public internet without any packet filtering.
* State 2: Active. The terminal will output `Status: active`, followed immediately by a highly detailed, tabular breakdown of every single port that is currently allowed to transmit data. (e.g., `22/tcp ALLOW Anywhere`, indicating your SSH connection is secure but functional).
6. The Verbose Override (Optional): If the firewall is active but you need to see exactly how it is handling default traffic (e.g., is it set to deny all incoming traffic by default?), you must append the `verbose` flag to the command:

sudo ufw status verbose

Press Enter. The output will now include the master routing rules (e.g., `Default: deny (incoming), allow (outgoing)`).

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.