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. What to debug 2. Features of...
FFMPEG 3.4.1 version parameter details Usage: ffm...
This article example shares the specific code of ...
Overview Today we will mainly share how to config...
Open the folder C:\web\mysql-8.0.11 that you just...
Table of contents JSX environment construction Se...
To debug js code, you need to write debugger in t...
During the development process, I often encounter...
In Node.js, a .js file is a complete scope (modul...
Table of contents style scoped style module State...
Netease Kanyouxi official website (http://kanyoux...
Table of contents 1. Component Introduction 2. Co...
Preface This article records a problem I encounte...
Table of contents Overview 1. Separation of front...
<br />When the page contains <img src=&qu...