How can I change the firewall port in CentOS 7?

To modify the port configuration of CentOS 7 firewall, you can follow these steps:

  1. Connect to a CentOS 7 server using SSH.
  2. To check the current firewall status, input the following command:
sudo systemctl status firewalld
  1. If the firewall is currently running, you can use the following command to stop the firewall:
sudo systemctl stop firewalld
  1. To check the current firewall rules, type the following command:
sudo firewall-cmd --list-all
  1. To open the required ports for modification, such as TCP ports 80 and 443, use the following command:
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
  1. Reload the firewall configuration to make the changes take effect.
sudo firewall-cmd --reload
  1. View the new firewall rules.
sudo firewall-cmd --list-all
  1. Finally, activate the firewall and set it to start up automatically.
sudo systemctl start firewalld
sudo systemctl enable firewalld

This successfully modified the port configuration of the CentOS 7 firewall. Remember to only open necessary ports when modifying firewall rules to ensure server security.

 

 

More tutorials

What are the steps for configuring environment variables in CentOS 7?(Opens in a new browser tab)

How to enable a port on a Linux operating system.(Opens in a new browser tab)

Common errors that occur when using Nginx for connections.(Opens in a new browser tab)

How to check the process corresponding to a port number in Linux?(Opens in a new browser tab)

How can I install MySQL on Rocky Linux 9?(Opens in a new browser tab)

Leave a Reply 0

Your email address will not be published. Required fields are marked *