Block Unauthorized Access By Firewall

ufw
firewalld
Linux
security
blocking
unauthorized access
IP range
This article provides instructions on how to prevent unauthorized access to a Linux system by utilizing the `ufw` and `firewalld` tools. It explains the steps needed for both tools, including the necessary commands to deny connections from specific IP ranges and port numbers.
Published

July 1, 2024


ufw

sudo ufw deny from <ip_range> port <port>

firewalld

sudo firewall-cmd --add-rich-rule='rule family="ipv4" source address="<ip_range>" port protocol="tcp" port="<port>" drop'