DEV Community

Cover image for To install Firewall Command In Centos_linux
MuthuKumar
MuthuKumar

Posted on • Edited on

To install Firewall Command In Centos_linux

STEP 1:

Update your package repository

sudo yum update
Enter fullscreen mode Exit fullscreen mode

STEP 2:

install firewalld

sudo yum install firewalld
Enter fullscreen mode Exit fullscreen mode

STEP 3:

Start the firewalld service and enable it to start at boot:

sudo systemctl start firewalld
sudo systemctl enable firewalld
Enter fullscreen mode Exit fullscreen mode

STEP 4:

You can check the status of the firewalld service:

sudo systemctl status firewalld
Enter fullscreen mode Exit fullscreen mode
  • That's it! You now have firewalld installed and running on your CentOS system. You can configure your firewall rules using the firewall-cmd command. Here are a few examples of how to use firewall-cmd to configure your firewall:

STEP 5:

Allow incoming traffic on a specific port (e.g., port 80 for HTTP):

sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
Enter fullscreen mode Exit fullscreen mode

STEP 6:

Reload the firewall to apply the changes:

bash:

sudo firewall-cmd --reload
Enter fullscreen mode Exit fullscreen mode

STEP 7:

List all open ports in the default zone (usually "public"):

sudo firewall-cmd --list-ports
sudo firewall-cmd --list-all
Enter fullscreen mode Exit fullscreen mode

STEP 8:

List all the services currently allowed through the firewall:

sudo firewall-cmd --list-services
Enter fullscreen mode Exit fullscreen mode

Top comments (0)