Skip to content

Tag: firewall

Firewall Management

Here’s a concise list of commands for managing firewalld on AlmaLinux:


Basic Commands

sudo systemctl start firewalld
sudo systemctl stop firewalld
sudo systemctl restart firewalld
sudo systemctl enable firewalld
sudo systemctl disable firewalld
sudo firewall-cmd --state

Managing Rules

sudo firewall-cmd --permanent --add-service=<service>
sudo firewall-cmd --permanent --remove-service=<service>
sudo firewall-cmd --permanent --add-port=<port>/tcp
sudo firewall-cmd --permanent --remove-port=<port>/tcp
sudo firewall-cmd --permanent --add-port=<xxx-yyy>/tcp
sudo firewall-cmd --permanent --add-port=<xxx-yyy>/udp
sudo firewall-cmd --reload

Viewing Configuration

sudo firewall-cmd --list-all
sudo firewall-cmd --list-ports
sudo firewall-cmd --list-services
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --query-service=<service>
sudo firewall-cmd --query-port=<port>/tcp

Zone Management

sudo firewall-cmd --get-zones
sudo firewall-cmd --permanent --zone=<zone> --add-service=<service>
sudo firewall-cmd --permanent --zone=<zone> --remove-service=<service>
sudo firewall-cmd --permanent --zone=<zone> --add-port=<port>/tcp
sudo firewall-cmd --permanent --zone=<zone> --remove-port=<port>/tcp

Direct Rules (Advanced)

sudo firewall-cmd --direct --add-rule ipv4 filter INPUT <priority> -p tcp --dport <port> -j ACCEPT
sudo firewall-cmd --direct --remove-rule ipv4 filter INPUT <priority> -p tcp --dport <port> -j ACCEPT
sudo firewall-cmd --direct --list-all