Configure firewalld on AlmaLinux and Rocky Linux
Learn the firewalld basics on AlmaLinux and Rocky Linux: zones, opening services and ports, permanent versus runtime rules, and IP-restricted access.
- Intermediate
- Linux VPS
- 2 min read
AlmaLinux and Rocky Linux use firewalld. It groups rules into zones; your network interface is normally in the public zone, which blocks incoming traffic except for the services you allow.
1. Make sure it is running
sudo dnf install -y firewalld
sudo systemctl enable --now firewalld
sudo firewall-cmd --state2. See what is allowed
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --list-allservices: should include ssh. If you changed the SSH port, ports: must include it.
Never remove ssh (or your custom SSH port) from the zone while you are connected over SSH, unless another rule still allows you in. If you lock yourself out, the browser console in the control panel still works.
Runtime vs permanent
firewalld keeps two configurations:
- Runtime rules apply immediately and vanish on reload or reboot.
- Permanent rules (with
--permanent) are saved but only apply after--reload.
The usual pattern is to add a permanent rule and reload:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reloadOpen a port
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reloadTo try a rule without committing to it, add it at runtime with a timeout. It disappears by itself after 10 minutes:
sudo firewall-cmd --add-port=8080/tcp --timeout=10mAllow a port from one IP only
A rich rule lets you open, for example, MariaDB only to your office address:
sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="198.51.100.7" port port="3306" protocol="tcp" accept'
sudo firewall-cmd --reloadRemove what you do not need
sudo firewall-cmd --permanent --remove-service=cockpit
sudo firewall-cmd --permanent --remove-port=8080/tcp
sudo firewall-cmd --reloadRemove cockpit only if you do not use the Cockpit web console.
Troubleshooting
- Port is open but the service still cannot be reached: check the service listens publicly with
sudo ss -tlnp. SELinux can also block non-standard ports;sudo ausearch -m avc -ts recentshows recent denials. - Rule works until reboot: you added it without
--permanent. Save the current runtime rules withsudo firewall-cmd --runtime-to-permanent. - Which zone am I editing? Rules without
--zonego to the default zone:sudo firewall-cmd --get-default-zone.
Next steps
Was this guide helpful?
Still stuck?
Ask RunRacks AI for a quick answer, or open a ticket and our team will take a look at your server.
Related guides
Security
Check the Windows Firewall rule for RDP port 12230
Find and verify the inbound TCP 12230 rule that lets Remote Desktop reach your RunRacks server, recreate it if it was deleted and scope it without locking yourself out.
- Intermediate
- Windows VPS · Admin RDP
- 5 min read
Security
Linux Security: Using aide for File Integrity Monitoring on VPS
AIDE builds a checksum database of your system files and reports anything that changed. This guide installs it, creates a baseline, tunes the rules and schedules daily checks on a Linux VPS.
- Advanced
- Linux VPS
- 6 min read
Security
iptables basics: list, allow, drop and save rules
Learn how iptables chains and rule order work, then build a small ruleset that allows SSH and web traffic, drops everything else and can be edited by line number.
- Intermediate
- Linux VPS
- 6 min read