Installing, Enabling, and Configuring a Linux Firewall

March 21, 2023

Introduction

In this blog post, we will guide you through the process of installing, enabling, and configuring firewalls on various Linux distributions, specifically Ubuntu/Debian, CentOS 7, CentOS Stream 8, Fedora, and Red Hat Enterprise Linux (RHEL). Firewalls play a crucial role in securing your system by controlling incoming and outgoing network traffic based on predefined rules. The default firewall for Ubuntu and Debian-based distributions is Uncomplicated Firewall (UFW), while CentOS and Fedora/RHEL use firewalld.

Please click on the headings below to expand.

Ubuntu/Debian: Installing and enabling UFW ▼

CentOS 7: Installing and enabling firewalld ▼

CentOS Stream 8/9: Installing and enabling firewalld ▼

Fedora & Red Hat Enterprise Linux (RHEL): Installing and enabling firewalld ▼

openSUSE: Installing and enabling firewalld ▼

Further Firewall Configuration

As stated above, allowing all incoming traffic is not recommended, but instead you should configure your firewall to limit services. Allowing all incoming traffic can expose your system to potential threats.

Please see below for additional configuration options

Uncomplicated Firewall (UFW): ▼

firewalld ▼

Conclusion

These are some of the common commands and ways to control both UFW and firewalld. Depending on your specific needs, you may need to dive deeper into each tool's documentation for more advanced use cases. We have now demonstrated how to install, enable, and configure the firewalls (UFW and firewalld) on Ubuntu/Debian, CentOS 7, CentOS Stream 8, Fedora, Red Hat Enterprise Linux (RHEL), and openSUSE.