Configure Firewall Using Firewall-CMD/Firewalld

LinuxLinuxBeginner
Practice Now

Introduction

As a system administrator, you need to manage the firewall settings on your Linux server to control network traffic and enhance the security of your system. In this challenge, you will learn how to configure the firewall using the firewall-cmd and firewalld commands.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`") subgraph Lab Skills linux/echo -.-> lab-389482{{"`Configure Firewall Using Firewall-CMD/Firewalld`"}} end

Configure the Firewall

Tasks

  • Task 1: Install the firewalld package if it's not already installed.
  • Task 2: Start and enable the firewalld service.
  • Task 3: Configure the firewall to allow HTTP (port 80) and HTTPS (port 443) traffic.
  • Task 4: Verify the firewall configuration.

Requirements

  • The default working directory for this challenge is ~/project.
  • Use the firewall-cmd command to manage the firewall.
  • The firewall should be configured to allow HTTP (port 80) and HTTPS (port 443) traffic.
  • Verify the firewall configuration using the firewall-cmd command.

Example

After completing the tasks, the output of firewall-cmd --list-all should look similar to the following:

public (active)
  target: default
  icmp-block-inversion: no
  interfaces:
  sources:
  services: http https
  ports:
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

Summary

In this challenge, you learned how to manage the firewall on a Linux system using the firewall-cmd and firewalld commands. You installed the firewalld package, started and enabled the firewalld service, and configured the firewall to allow HTTP and HTTPS traffic. By completing this challenge, you have gained practical experience in configuring and verifying firewall settings, which is an essential skill for system administrators.

Other Linux Tutorials you may like