zoukankan      html  css  js  c++  java
  • CENTER OS7关闭防火墙

    CentOS 7.0默认使用的是firewall作为防火墙,之前版本是使用iptables。
    所以在CentOS 7执行下面命令是无法查看防火墙状态的。

    [root@localhost ~]# service iptables status
    Redirecting to /bin/systemctl status iptables.service
    Unit iptables.service could not be found.

    查看防火墙是否关闭

    firewall-cmd --state

    [root@localhost ~]# firewall-cmd --state
    not running
    [root@localhost ~]#

    开启防火墙

    [root@localhost ~]# systemctl start firewalld
    [root@localhost ~]# firewall-cmd --state
    running
    [root@localhost ~]#

    关闭防火墙

    [root@localhost ~]# systemctl stop firewalld
    [root@localhost ~]# firewall-cmd --state
    not running
    [root@localhost ~]# 

    禁止firewall开机启动

    [root@localhost ~]# systemctl disable firewalld
    Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
    Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
    这样设置的话,下次重启开机的时候就会禁止firewall的启动,即关闭状态。

    设置firewall开机启动

    [root@localhost ~]# systemctl enable firewalld
    Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
    Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.
    这样设置之后,开机就会自动开启防火墙。

    显示防火墙应用列表

    [root@localhost ~]# firewall-cmd --list-all

    public (active)
    target: default
    icmp-block-inversion: no
    interfaces: ens33
    sources: 
    services: ssh dhcpv6-client
    ports: 
    protocols: 
    masquerade: no
    forward-ports: 
    source-ports: 
    icmp-blocks: 
    rich rules:

    [root@localhost ~]# firewall-cmd --add-service=ftp
    success
    [root@localhost ~]# firewall-cmd --list-all
    public (active)
    target: default
    icmp-block-inversion: no
    interfaces: ens33
    sources: 
    services: ssh dhcpv6-client ftp
    ports: 
    protocols: 
    masquerade: no
    forward-ports: 
    source-ports: 
    icmp-blocks: 
    rich rules:

    [root@localhost ~]#

    使用firewall-cmd --add-service=ftp 之后,列表显示出多了一个ftp服务。

     
    他强由他强,清风拂山冈。他横任他横,明月照大江。
  • 相关阅读:
    一步一步学习IdentityServer4 (4) 处理特殊需求之-登录等待页面
    php 打包下载
    nginx https反向代理tomcat
    the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf
    layui配置
    vue 学习一
    MyCAT+MySQL 搭建高可用企业级数据库集群——第3章 MyCat核心配置讲解
    第一模块·开发基础-第3章 作业讲解
    《扭转人生的40个哲学提问》 徐帆 著
    零基础学 JavaScript 全彩版 明日科技 编著
  • 原文地址:https://www.cnblogs.com/gucb/p/11156935.html
Copyright © 2011-2022 走看看