How to set up a firewall using FirewallD on CentOS 8
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 firewalldrnsudo 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 --permanentWhere 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 --permanentWhere 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 --reloadNote: The --permanent option makes the changes persistent across reboot. If you don't want to make the changes permanent, you can skip this option.
