Hot Article
- Centos7 closes and restarts the system firewall and opens firewall ports
- How IID server uses Xshell to connect to Linux (centos) server
- BT panel forgets the background login URL, and the solution to the security entrance verification failure
- The php domain name points to ip, how to use the specified ip address to access a server in the url request domain name in curl mode
- How to purchase a dedicated server
- Error connecting to MySQL: Cant connect to MySQL server (10060)
Centos7 closes and restarts the system firewall and opens firewall ports
- Author:Kevin
- Category:Server Maintain
- Release Time:2022-10-04
The default firewall of the Linux system installed by some people is not iptables, but firewall, then the firewall must be turned off in the following way.
>>>Turn off firewall
systemctl stop firewalld.service #stop firewall
systemctl disable firewalld.service #Prohibit firewall from starting
>>>Open the port
firewall-cmd --zone=public --add-port=80/tcp --permanent
command meaning
--zone #scope
--add-port=80/tcp #Add port, the format is: port/communication protocol
--permanent #Permanent effect, invalid after restart without this parameter
>>>Restart firewall
firewall-cmd --reload
Other common commands:
firewall-cmd --state ##Check the firewall status, whether it is running
firewall-cmd --reload ##Reload the configuration, for example, after adding rules, you need to execute this command
firewall-cmd --get-zones ##List supported zones
firewall-cmd --get-services ##List the supported services, the services in the list are allowed
firewall-cmd --query-service ftp ##Check whether the ftp service is supported, return yes or no
firewall-cmd --add-service=ftp ##Temporarily open ftp service
firewall-cmd --add-service=ftp --permanent ##Permanently open ftp service
firewall-cmd --remove-service=ftp --permanent ##Permanently remove the ftp service
firewall-cmd --add-port=80/tcp --permanent ##Add port 80 permanently
iptables -L -n ##View the rules, this command is the same as iptables
man firewall-cmd ##View help
For more commands, use firewall-cmd --help to view the help file
>>> CentOS 7.0 uses firewall as the firewall by default, and iptables must be reset
1. Turn off the firewall directly
systemctl stop firewalld.service #stop firewall
systemctl disable firewalld.service #Prohibit firewall from starting
2. Set iptables service
yum -y install iptables-services
If you want to modify the firewall configuration, such as adding firewall port 3306
vi /etc/sysconfig/iptables
add rules
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
After saving and exiting
systemctl restart iptables.service #Restart the firewall to make the configuration take effect
systemctl enable iptables.service #Set the firewall to start at boot
related topic
- linux how to change the user password (linux command to change the password)
- What should I do if the proxy server link fails to respond?
- What should I do if the cloud storage space is full (solutions for clearing the cloud storage space)
- inuxfind-name fuzzy query
- How to solve the Windows 10 prompt "The built-in administrator cannot activate this application"?
- Merge the /home directory into the / directory under CentOS