-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux Firewall Configuration
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to firewalls on Linux, covering Arch Linux, CachyOS, and other distributions including UFW, firewalld, and iptables configuration.
Firewall controls network traffic to/from your system.
Types:
- Packet filter: Blocks/allows packets
- Stateful: Tracks connections
- Application: Controls by application
Why use a firewall:
- Security: Block unauthorized access
- Privacy: Control outgoing traffic
- Protection: Prevent attacks
Arch/CachyOS:
# Install UFW
sudo pacman -S ufw
# Enable service
sudo systemctl enable --now ufwDebian/Ubuntu:
sudo apt install ufw
sudo ufw enableFedora:
sudo dnf install ufwBasic setup:
# Default deny incoming
sudo ufw default deny incoming
# Default allow outgoing
sudo ufw default allow outgoing
# Enable firewall
sudo ufw enableAllow specific ports:
# Allow SSH
sudo ufw allow 22/tcp
# Allow HTTP
sudo ufw allow 80/tcp
# Allow HTTPS
sudo ufw allow 443/tcp
# Allow by service name
sudo ufw allow sshArch/CachyOS:
# Install firewalld
sudo pacman -S firewalld
# Enable service
sudo systemctl enable --now firewalldFedora:
sudo dnf install firewalld
sudo systemctl enable firewalldUsing firewall-cmd:
# Check status
sudo firewall-cmd --state
# List zones
sudo firewall-cmd --list-all-zones
# Add service
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reloadiptables is low-level firewall tool.
Chains:
- INPUT: Incoming traffic
- OUTPUT: Outgoing traffic
- FORWARD: Routed traffic
Allow SSH:
# Allow SSH
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# Allow loopback
sudo iptables -A INPUT -i lo -j ACCEPT
# Default deny
sudo iptables -P INPUT DROPCheck rules:
# UFW
sudo ufw status verbose
# firewalld
sudo firewall-cmd --list-all
# iptables
sudo iptables -L -vTest ports:
# Test port
nc -zv hostname 22
# Or use telnet
telnet hostname 22This guide covered firewall configuration using UFW, firewalld, and iptables for Arch Linux, CachyOS, and other distributions.
- Security Configuration - Security setup
- SSH Configuration - SSH setup
- ArchWiki Firewalls: https://wiki.archlinux.org/title/Firewalls
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.