To set up a firewall using FirewallD on CentOS 8, you can follow these steps:
- Make sure FirewallD is installed on your system by running the command:
sudo yum install firewalld
- Start and enable the firewall service by running the commands:
sudo systemctl start firewalld
sudo systemctl enable firewalld
- To check the status of the firewall, use the command:
sudo firewall-cmd --state
- To add a new service to the firewall, use the command:
sudo firewall-cmd --add-service=service_name --permanent
Where service_name can be http, https, ssh, etc.
- To check the list of services currently allowed by the firewall, use the command:
sudo firewall-cmd --list-services
- To add a new port to the firewall, use the command:
sudo firewall-cmd --add-port=port_number/protocol --permanent
Where port_number is the port number you want to open and protocol can be tcp or udp.
- To check the list of ports currently allowed by the firewall, use the command:
sudo firewall-cmd --list-ports
- To reload the firewall configuration, use the command:
sudo firewall-cmd --reload
Note: The –permanent option makes the changes persistent across reboot. If you don’t want to make the changes permanent, you can skip this option.