Port Management and IP Security with UFW (Ubuntu) and Firewalld (AlmaLinux)
The most basic way to ensure security on Linux servers is to close unused ports to the outside world and block suspicious IP addresses. In this article, we will talk about the software used in Ubuntu/Debian infrastructures. UFW and used in CentOS/AlmaLinux infrastructures firewalld You can find the most popular commands of the services.
Part A: UFW Commands for Ubuntu / Debian Servers
UFW (Uncomplicated Firewall) has a very simple and straightforward port management tool:
- Activating UFW:
ufw enable - Opening a Specific Port (Ex: Game Input Port):
ufw allow 22000/tcp - Completely Blocking (Banning) a Suspicious IP Address:
ufw deny from 185.123.45.67 to any - Listing Rules and Status:
ufw status verbose
Part B: Firewalld Commands for AlmaLinux / CentOS Servers
Advanced firewall commands that come by default in enterprise RedHat-based Linux distributions:
- Permanently Opening a Specific Port:
firewall-cmd --zone=public --add-port=80/tcp --permanent - Blocking (Dropping) a Malicious IP Address:
firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='185.123.45.67' drop" - Activating the Changes Made (Restart):
firewall-cmd --reload - Listing Open Ports:
firewall-cmd --list-ports
This article is specially prepared for PvPServer.