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

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay