Centos7 commands to view, close, and open the firewall

0 Introduction

Today I installed Ubuntu on another computer. I wanted to netcat the echo server of the main computer (centos7 virtual machine), but found that I could not connect, but the two computers could be pinged. I checked some information and found that the firewall of centos was not turned off. I specifically recorded the opening and closing commands of the firewall.

1Firewall status query

The command to view the status of the firewall is:
sudo systemctl status firewalld
Insert picture description here
if active is active (running), it is turned on, otherwise it is turned off as shown in the figure.

2 Turn on the firewall

There are two ways to turn on the firewall. One is that it will return to its original state after it is turned on, that is, it will be turned on temporarily. The command is: the
sudo systemctl start firewalld
other is that it will not return to its original state after being turned on. The command is:
sudo systemctl enable firewalld
this way of input The command will only take effect after the system is restarted.

3 Turn off the firewall

There are two ways to turn off the firewall. If you need to turn off the firewall temporarily, the command is.
sudo systemctl stop firewalld
If you need to restart the firewall and still turn it off, execute the command
sudo systemctl disable firewalld

Guess you like

Origin blog.csdn.net/MoonWisher_liang/article/details/107936382