Firewall Rocky
Introduction
firewalld is a firewall management tool for Linux operating systems.
It provides firewall features by acting as an interface to the netfilter framework of the Linux kernel through the nftables userspace utility (before version v0.6.0, the iptables backend),
acting as an alternative to the nft command-line program.
The name firewalld follows the Unix convention for naming system daemons by adding the letter "d".
firewalld is written in
Python
.
It was intended to be ported to
C++
, but the porting project was abandoned in January 2015.
Check the current status
To check the status of firewalld execute
sudo systemctl status -l firewalld
● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2026-11-17 00:00:01 EEST; 2h 55min ago 1794945307 Docs: man:firewalld(1) Main PID: 783 (firewalld) Tasks: 2 CGroup: /system.slice/firewalld.service └─783 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid Nov 17 11:57:07 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon... Nov 17 11:57:07 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon. Nov 17 11:57:07 localhost.localdomain firewalld[783]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be removed in a future release. Please consider disabling it now.
Firewall
List of open ports
firewall-cmd --list-ports
8443/tcp 3389/tcp 2222/tcp
List of active zones
firewall-cmd --get-active-zones
public interfaces: enp0s3 enp0s8
Full list
sudo firewall-cmd --list-all
public (active) target: default icmp-block-inversion: no interfaces: enp0s3 enp0s8 sources: services: dhcpv6-client http https ssh ports: 8443/tcp 3389/tcp 2222/tcp protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
Open a port
sudo firewall-cmd --zone=public --add-port=19999/tcp --permanent
sucess
Then the firewall needs to be restarted
sudo firewall-cmd --reload
sucess
Check
sudo firewall-cmd --list-ports
8443/tcp 3389/tcp 2222/tcp 19999/tcp
If you are suddenly curious about what port 19999 is - it is used by Locust
Block a port
sudo firewall-cmd --remove-port=22/tcp --permanent
sudo firewall-cmd --remove-port=53/udp --permanent
sudo firewall-cmd --reload
Allow a service
sudo firewall-cmd --add-service=https
Block a service
sudo firewall-cmd --remove-service=https
Add an IP to the "white" list
To add a single IP address
sudo firewall-cmd --permanent --add-source=192.168.56.101
To add the whole subnet 255.255.255.0 execute
sudo firewall-cmd --permanent --add-source=192.168.2.0/24
Remove an IP from the "white" list
To remove a single IP address
sudo firewall-cmd --permanent --remove-source=192.168.2.50
To remove the whole subnet 255.255.255.0 execute
sudo firewall-cmd --permanent --remove-source=192.168.2.50/24
Block an IP
To block incoming connections from a specific IP address, use rich-rule
sudo firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='192.168.2.50' reject"
View all rich-rules
To view all existing rich-rules execute
sudo firewall-cmd --list-rich-rules
rule family="ipv4" source address="192.168.56.109" reject
Remove a rule
To remove an existing rich-rule execute
sudo firewall-cmd --permanent --remove-rich-rule='rule family="ipv4" source address="192.168.56.109" reject'
sudo firewall-cmd --permanent --remove-rich-rule='rule family="ipv4" source address="192.168.1.100" port protocol="tcp" port="3306" accept'
Article author: Andrei Olegovich