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

By RunRacks Team · Published

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

Terminal
sudo dnf install -y firewalld
sudo systemctl enable --now firewalld
sudo firewall-cmd --state

2. See what is allowed

Terminal
sudo firewall-cmd --get-active-zones
sudo firewall-cmd --list-all

services: should include ssh. If you changed the SSH port, ports: must include it.

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:

Terminal
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Open a port

Terminal
sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload

To try a rule without committing to it, add it at runtime with a timeout. It disappears by itself after 10 minutes:

Terminal
sudo firewall-cmd --add-port=8080/tcp --timeout=10m

Allow a port from one IP only

A rich rule lets you open, for example, MariaDB only to your office address:

Terminal
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 --reload

Remove what you do not need

Terminal
sudo firewall-cmd --permanent --remove-service=cockpit
sudo firewall-cmd --permanent --remove-port=8080/tcp
sudo firewall-cmd --reload

Remove 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 recent shows recent denials.
  • Rule works until reboot: you added it without --permanent. Save the current runtime rules with sudo firewall-cmd --runtime-to-permanent.
  • Which zone am I editing? Rules without --zone go 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.

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

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