To set up a firewall using FirewallD on CentOS 8, follow these steps:
sudo dnf install firewalld
sudo systemctl enable firewalld sudo systemctl start firewalld
firewall-cmd command with the --state option:firewall-cmd --state
This will show the current firewall status, which should be running.
--add-port option:sudo firewall-cmd --add-port=22/tcp
This will allow incoming traffic on port 22 (SSH).
--add-source option:sudo firewall-cmd --add-source=192.168.1.0/24
This will allow incoming traffic from IP addresses in the range 192.168.1.0 to 192.168.1.255.
--permanent option:sudo firewall-cmd --permanent --add-port=22/tcp sudo firewall-cmd --permanent --add-source=192.168.1.0/24
--reload option:sudo firewall-cmd --reload
You can use the firewall-cmd command to view the current firewall rules and make additional changes as needed. For more information, see the FirewallD documentation.