Centos 7 firewall firewalld related basic commands

[Note] Centos7Under 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, firewallddoes not have the function of a firewall, but iptablesis the same as , both of them just maintain the rules, and what really plays the role of a firewall is in the kernel netfilter.

1. Install firewalld firewall

yum install firewalld

2. firewalld basic commands

In fact, it is the use of systemctlthe command , Centos 7which is recommended in the systemctlsystem 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 systemctland 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】 rootPermission .

  • Get the version firewalldof
    $ firewall-cmd --version #或 firewall-cmd -V
    0.8.2
    
  • Get command help documentation
    $ firewall-cmd --help #或  firewall-cmd -h
    
  • Get the status firewalldof
    $ firewall-cmd --state
    running  # 表示正在运行	
    

More usage commands are updated and supplemented from time to time. . .

Guess you like

Origin blog.csdn.net/peng2hui1314/article/details/115790423