0Pricing
Linux Networking & TCP/IP for Developers · Aula

Firewall do Linux (Netfilter/iptables)

Entenda os fundamentos dos firewalls do Linux usando `iptables` para filtrar o tráfego e proteger seus sistemas.

Firewall do Linux (Netfilter/iptables) é uma aula grátis de Linux Networking & TCP/IP for Developers no CoddyKit. Esta é a aula 3 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Linux Networking & TCP/IP for Developers, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Linux Networking & TCP/IP for Developers inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Firewalls: Your Network Guardian

What is a firewall? It's like a security guard for your network, controlling what traffic goes in and out. In Linux, the core firewall framework is called Netfilter. We use a command-line tool called iptables to manage its rules.

Netfilter: The Kernel's Core

Netfilter is a powerful framework built right into the Linux kernel. It allows different kernel modules to inspect, modify, and drop network packets.

Think of it as the engine behind the firewall. It provides "hooks" where packet processing can be intercepted.

`iptables`: Managing Firewall Rules

While Netfilter is in the kernel, iptables is the command-line utility you use to interact with it. It lets you define rules that tell Netfilter what to do with specific packets.

These rules are organized into tables and chains, which we'll explore next.

`iptables` Chains: Traffic Paths

iptables organizes rules into chains. These are ordered lists of rules that packets are checked against. The three most common built-in chains are:

  • INPUT: For packets destined for the local system.
  • OUTPUT: For packets originating from the local system.
  • FORWARD: For packets passing through the system (e.g., a router).

Default Actions: Chain Policies

Each chain has a default policy, which is the action taken if no rule in the chain matches a packet. Common policies are:

  • ACCEPT: Let the packet through.
  • DROP: Silently discard the packet (sender gets no response).
  • REJECT: Discard the packet and send an error message back to the sender.

It's common to set default policies to DROP for security.

Viewing Current `iptables` Rules

Before adding rules, it's good to see what's already there. You can list all current iptables rules with the -L option. Adding -n shows IP addresses numerically, and -v adds verbosity.

sudo iptables -L -n -v

Allowing Inbound SSH Traffic

Let's add a rule to allow incoming SSH connections (port 22). We'll append (-A) this rule to the INPUT chain, specifying TCP protocol (-p tcp) and destination port (--dport 22). The action (-j) will be ACCEPT.

sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT

Blocking Outbound Ping Requests

Now, let's block all outbound ping requests (ICMP protocol). We'll append this rule to the OUTPUT chain, specifying the ICMP protocol. The action will be DROP.

This means your system won't send ping requests, but might still receive them if not blocked on INPUT.

sudo iptables -A OUTPUT -p icmp -j DROP

Making Rules Permanent

iptables rules are volatile; they disappear on reboot! To make them permanent, you need to save them. On many systems, you'd use iptables-save to export rules and iptables-restore to load them.

Some Linux distributions use specific services (like netfilter-persistent) or files (e.g., /etc/sysconfig/iptables) to manage persistence.

Firewall Chains Check

Based on what you've learned, which iptables chain would typically handle network packets that are trying to reach a service running on your local machine?

Recap: `iptables` Firewall Basics

You've learned about Netfilter, the kernel's firewall framework, and iptables, the user-space tool to manage its rules. We covered the main chains (INPUT, OUTPUT, FORWARD) and policies (ACCEPT, DROP, REJECT).

You also saw how to list, add basic rules, and the importance of saving them for persistence. This is a crucial step in securing any Linux system!

Perguntas Frequentes

A aula “Firewall do Linux (Netfilter/iptables)” é grátis?

Sim — o texto completo de “Firewall do Linux (Netfilter/iptables)” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Linux Networking & TCP/IP for Developers, atualize para CoddyKit PRO. O curso de Linux Networking & TCP/IP for Developers inclui 4 aulas no total.

O que vou aprender em “Firewall do Linux (Netfilter/iptables)”?

Entenda os fundamentos dos firewalls do Linux usando `iptables` para filtrar o tráfego e proteger seus sistemas. Você pratica Linux Networking & TCP/IP for Developers com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Linux Networking & TCP/IP for Developers?

Nenhuma experiência prévia é necessária. Linux Networking & TCP/IP for Developers no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 3 de 4.

Quanto tempo leva a aula “Firewall do Linux (Netfilter/iptables)”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Linux Networking & TCP/IP for Developers?

Sim. Cada aula de Linux Networking & TCP/IP for Developers inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Captura de Pacotes com Wireshark/tcpdump
  2. Ferramentas de Desempenho de Rede
  3. Firewall do Linux (Netfilter/iptables)
  4. Diagnóstico de DNS com dig e nslookup
← Voltar para Linux Networking & TCP/IP for Developers