Sobes.tech
Junior — Middle

How is firewall configuration performed in the Linux operating system?

sobes.tech AI

Answer from AI

In Linux, firewall configuration is usually carried out using utilities that manage packet filtering rules. The main tools are:

  • iptables — a classic tool for setting up packet filtering in the Linux kernel.
  • nftables — a modern replacement for iptables, more flexible and efficient.
  • firewalld — a service with dynamic firewall management, using nftables or iptables under the hood.

Example of basic configuration with iptables:

# Allow incoming SSH connections
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# Block all other incoming connections
sudo iptables -P INPUT DROP

# Allow outgoing connections
sudo iptables -P OUTPUT ACCEPT

To save rules permanently, special utilities or configuration files are used, as iptables rules are reset after reboot.

With firewalld, configuration is simpler:

# Allow SSH
sudo firewall-cmd --permanent --add-service=ssh

# Reload firewalld to apply changes
sudo firewall-cmd --reload

Thus, firewall configuration in Linux depends on the chosen tool and security goals.

How is firewall configuration performed in the Linux… - sobes.tech