Table of contents
[Note] Centos7
Under the default firewall has changed firewalld
, and is no longer the previous one iptables
. If you buy a server from Alibaba Cloud or Tencent Cloud, you generally need to install it yourself without a firewall.
[Note] In fact, firewalld
does not have the function of a firewall, but iptables
is the same as , both of them just maintain the rules, and what really plays the role of a firewall is in the kernel netfilter
.
- Reference link: firewalld official website
1. Install firewalld firewall
yum install firewalld
2. firewalld basic commands
In fact, it is the use of systemctl
the command , Centos 7
which is recommended in the systemctl
system instead service
.
Of course, if you are not used to it, you can continue to use it service
, but, in fact, the command will be automatically redirected to systemctl
and used.
# 查看状态
systemctl status firewalld
# OR
service firewalld status
# 启动
systemctl start firewalld
# OR
service firewalld start
# 停止运行
systemctl stop firewalld
# OR
service firewalld stop
# 禁止开机启动
systemctl disable firewalld
# 允许开机启动
systemctl enable firewalld
3. firewall-cmd basic command
【Note】 root
Permission .
- Get the version
firewalld
of$ firewall-cmd --version #或 firewall-cmd -V 0.8.2
- Get command help documentation
$ firewall-cmd --help #或 firewall-cmd -h
- Get the status
firewalld
of$ firewall-cmd --state running # 表示正在运行
More usage commands are updated and supplemented from time to time. . .