查看/开启/关闭防火墙(View / turn on / off firewall)

CentOS 5/CentOS 6

在CentOS 5和CentOS 6系统中,关于如何开启防火墙、关闭防火墙、查看防火墙运行状态,请参考以下信息:

  • 开启防火墙

     
    service iptables start

service iptables start
  • 关闭防火墙

     
    service iptables stop

service iptables stop
  • 查看防火墙运行状态

     
    service iptables status

service iptables status

CentOS 7/Red Hat 7/Alibaba Cloud Linux 2

在CentOS 7、Red Hat和Alibaba Cloud Linux 2系统中,关于如何开启防火墙、关闭防火墙、查看防火墙运行状态,请参考以下信息:

  • 开启防火墙

     
    systemctl start firewalld.service

systemctl start firewalld.service
  • 关闭防火墙

     
    systemctl stop firewalld.service

systemctl stop firewalld.service
  • 查看防火墙运行状态

     
    firewall-cmd –state

firewall-cmd --state

Ubuntu

在Ubuntu系统中,关于如何开启防火墙、关闭防火墙、查看防火墙运行状态,请参考以下信息:

  • 开启防火墙

     
    ufw enable

ufw enable
  • 关闭防火墙

     
    ufw disable

ufw disable
  • 查看防火墙运行状态

     
    ufw status

ufw status

Debian

在Debian系统中,默认没有安装防火墙,可以通过清空防火墙策略,删除相关屏蔽规则。具体操作如下所示:

注意:清空策略前,请务必备份防火墙策略。

注意:清空策略前,请务必备份防火墙策略。

  • 依次执行以下命令,备份防火墙策略。

     
    touch [$Iptables]iptables-save > [$Iptables]

    说明:[$Iptables]为防火墙策略的备份文件地址。

touch [$Iptables]iptables-save > [$Iptables]
  • 执行以下命令,清空防火墙策略。

     
    iptables -F

iptables -F
————————

CentOS 5/CentOS 6

In CentOS 5 and CentOS 6 systems, please refer to the following information on how to turn on the firewall, turn off the firewall and view the firewall running status:

  • 开启防火墙

     
    service iptables start

service iptables start
  • 关闭防火墙

     
    service iptables stop

service iptables stop
  • 查看防火墙运行状态

     
    service iptables status

service iptables status

CentOS 7/Red Hat 7/Alibaba Cloud Linux 2

In CentOS 7, red hat and Alibaba cloud Linux 2 systems, please refer to the following information on how to turn on the firewall, turn off the firewall and view the firewall running status:

  • 开启防火墙

     
    systemctl start firewalld.service

systemctl start firewalld.service
  • 关闭防火墙

     
    systemctl stop firewalld.service

systemctl stop firewalld.service
  • 查看防火墙运行状态

     
    firewall-cmd –state

firewall-cmd --state

Ubuntu

In Ubuntu system, please refer to the following information about how to turn on the firewall, turn off the firewall and view the firewall running status:

  • 开启防火墙

     
    ufw enable

ufw enable
  • 关闭防火墙

     
    ufw disable

ufw disable
  • View firewall running status
     
    ufw status
ufw status

Debian

In Debian system, no firewall is installed by default. You can clear the firewall policy and delete the relevant shielding rules. The specific operations are as follows:

Note: before emptying the policy, be sure to back up the firewall policy.

Note: before emptying the policy, be sure to back up the firewall policy.

  • Execute the following commands in sequence to back up the firewall policy.
     
    touch [$Iptables]iptables-save > [$Iptables]
    Description: [$iptables] is the backup file address of firewall policy.
touch [$Iptables]iptables-save > [$Iptables]
  • Execute the following command to clear the firewall policy.
     
    iptables -F
iptables -F