0Pricing
Linux Command Line Mastery · Lezione

Gestione del firewall: `ufw`, `firewalld`, `iptables`

Impari a configurare e gestire i firewall per proteggere il sistema Linux dagli accessi non autorizzati.

Gestione del firewall: `ufw`, `firewalld`, `iptables` è una lezione Linux Command Line Mastery gratuita su CoddyKit. Questa è la lezione 2 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Linux Command Line Mastery, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Linux Command Line Mastery include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

What's a Firewall?

A firewall acts as a security guard for your computer or network. It controls incoming and outgoing network traffic by analyzing data packets and deciding whether to allow or block them based on a set of predefined rules.

Think of it as a filter that protects your system from unauthorized access and malicious threats.

Introducing UFW

UFW, which stands for "Uncomplicated Firewall," is a user-friendly front-end for iptables, the complex default firewall utility in Linux. It's designed to make firewall management much simpler, especially for users on Debian-based systems like Ubuntu.

UFW simplifies common tasks like opening or closing ports.

UFW Status & Control

Before making changes, it's good practice to check UFW's current status. You can also easily enable or disable it.

Try running these commands:

sudo ufw status
sudo ufw enable
sudo ufw disable

UFW: Allow Services

UFW allows you to open ports for common services by their name, which is very convenient. For example, to allow SSH or HTTP traffic, you just use the service name.

Let's try allowing SSH and HTTP:

sudo ufw allow ssh
sudo ufw allow http
sudo ufw status verbose

UFW: Allow Custom Ports

Sometimes you need to open a specific port that isn't a named service. You can do this by specifying the port number and the protocol (TCP or UDP).

Here's how to allow port 8080 for TCP and 53 for UDP:

sudo ufw allow 8080/tcp
sudo ufw allow 53/udp
sudo ufw status verbose

Introducing Firewalld

Firewalld is another popular firewall management tool, often found on Red Hat-based systems like CentOS and Fedora. Unlike UFW, Firewalld is a dynamic firewall manager.

It uses zones to define different trust levels for network connections, allowing you to apply rules based on where the connection originates.

Firewalld Status & Zones

With Firewalld, you can check its status and explore the various zones it uses. Zones like public, home, or internal have different default rules.

Check the status and active zones:

sudo systemctl status firewalld
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --get-zones

Firewalld: Manage Services

To manage services with Firewalld, you specify the zone and the service name. Changes are temporary by default; use --permanent to make them stick after a reboot, then --reload to apply.

Let's add HTTP service to the public zone permanently:

sudo firewall-cmd --zone=public --add-service=http --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --list-services --zone=public

Firewalld: Manage Ports

Similar to services, you can open or close specific port numbers in a Firewalld zone. Remember to specify the protocol (TCP or UDP) and use --permanent for lasting changes.

Here's how to open port 8080 for TCP permanently:

sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --list-ports --zone=public

Firewall Commands Check

Time for a quick check! Which of the following statements about firewall management in Linux are true?

Recap: Firewall Essentials

In this lesson, we explored how to manage firewalls on Linux systems to enhance security. We covered two main tools:

  • UFW (Uncomplicated Firewall): A simple interface for iptables, popular on Debian/Ubuntu, allowing easy control over services and ports.
  • Firewalld: A dynamic firewall manager used on RHEL/CentOS systems, which organizes rules into zones for flexible security policies.

Understanding these tools is crucial for securing your Linux server or workstation.

Domande Frequenti

La lezione «Gestione del firewall: `ufw`, `firewalld`, `iptables`» è gratuita?

Sì — il testo completo di «Gestione del firewall: `ufw`, `firewalld`, `iptables`» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Linux Command Line Mastery, passa a CoddyKit PRO. Il corso Linux Command Line Mastery include 4 lezioni in totale.

Cosa imparerò in «Gestione del firewall: `ufw`, `firewalld`, `iptables`»?

Impari a configurare e gestire i firewall per proteggere il sistema Linux dagli accessi non autorizzati. Eserciti Linux Command Line Mastery con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Linux Command Line Mastery?

Non è richiesta alcuna esperienza precedente. Linux Command Line Mastery su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 2 di 4.

Quanto tempo richiede la lezione «Gestione del firewall: `ufw`, `firewalld`, `iptables`»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Linux Command Line Mastery?

Sì. Ogni lezione Linux Command Line Mastery include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Diagnostica di rete: `traceroute`, `nslookup`, `dig`
  2. Gestione del firewall: `ufw`, `firewalld`, `iptables`
  3. Gestione delle chiavi della shell sicura
  4. Catturare e analizzare il traffico con tcpdump
← Torna a Linux Command Line Mastery