How can I change the firewall port in CentOS 7?
To modify the port configuration of CentOS 7 firewall, you can follow these steps:
- Connect to a CentOS 7 server using SSH.
- To check the current firewall status, input the following command:
sudo systemctl status firewalld
- If the firewall is currently running, you can use the following command to stop the firewall:
sudo systemctl stop firewalld
- To check the current firewall rules, type the following command:
sudo firewall-cmd --list-all
- 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
- Reload the firewall configuration to make the changes take effect.
sudo firewall-cmd --reload
- View the new firewall rules.
sudo firewall-cmd --list-all
- 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)