The corresponding Linux system version in the following situation is CentOS7. If the environment used is CentOS6, please use service iptables state/start/stop/restart to replace the corresponding systemctl status /start/stop/restart firewalld.service command; 1. Check the current status of the firewallMethod 1 [root@hu ~]# firewall-cmd --state not running ---Not running [root@hu ~]# firewall-cmd --state Running --- Running Method 2 [root@hu ~]# systemctl status firewalld.service Normal operation 👇 Abnormal/Not running👇 2. Start the firewall service[root@hu ~]# systemctl start firewalld.service 3. Disable the firewall service[root@hu ~]# systemctl stop firewalld.service 4. Open the specified port#Add the --permanent parameter, restart the service to take effect and permanently take effect; #If the --permanent parameter is not added, it will take effect immediately and will become invalid after the service is restarted; [root@hu ~]# firewall-cmd --zone=public --add-port=8080/tcp --permanent success [root@hu ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent success #Restart the service to make the open port take effect [root@hu ~]# firewall-cmd --reload success #4.1. Verify whether the newly opened port is effective. Yes means it is effective, and no means it is not invalid. [root@hu ~]# firewall-cmd --zone=public --query-port=8080/tcp yes 5. Remove the specified port and restart the firewall service to take effect[root@hu ~]# firewall-cmd --zone=public --remove-port=8080/tcp --permanent #Command to verify whether the removal is successful [root@hu ~]# firewall-cmd --zone=public --query-port=80/tcp #Or check the ports currently open on the firewall [root@hu ~]# firewall-cmd --permanent --zone=public --list-ports 8081/tcp 3306/tcp 111/tcp 111/udp 2049/tcp 2049/udp 1001/tcp 1001/udp 1002/tcp 1002/udp 30001/tcp 30002/udp 80/tcp 8080/tcp #Add multiple ports by configuring multiple --add-port parameters, for example: [root@hu ~]# firewall-cmd --zone=public --add-port=80/tcp --add-port=8080/tcp --permanent 6. Restart the firewallMethod 1 [root@hu ~]# systemctl restart firewalld.service Method 2 [root@hu ~]# firewall-cmd --reloadsuccess 7. Set the firewall to start automatically at boot[root@hu ~]# systemctl enable firewalld.service #Restart the machine and check the firewall status[root@hu ~]# reboot .. .. .. [root@hu ~]# firewall-cmd --state Running --- indicates that the boot is successful SummarizeThis is the end of this article about CentOS7 firewall and port related commands. For more related CentOS7 firewall and port content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of the difference between JavaScript spread operator and rest operator
>>: Dynamic starry sky background implemented with CSS3
Table of contents 1. Reverse the numbers 2. Get t...
1. Add the following code to http{} in nginx.conf...
Docker takes up a lot of space. Whenever we run c...
In the table header, you can define the light bor...
This article introduces and shares the responsive...
Problem description: Recently, there is a demand ...
Since 2019, both Android and IOS platforms have s...
Table of contents 1. The significance of users an...
This article describes how to build a phalcon env...
The Docker daemon uses HTTP_PROXY , HTTPS_PROXY ,...
1. The color of the scroll bar under xhtml In the ...
As the domestic network environment continues to ...
Table of contents Basic concepts of components Th...
Preface In the previous article, we mainly learne...
I recently watched Rich Harris's <Rethinki...