zoukankan      html  css  js  c++  java
  • linux 常用命令(二)——(centos6.8-centos7)防火墙的启动、关闭

    centos 6.8 [centos6.5]:

      查看chkconfig列表里面是否有iptables的服务:

    chkconfig | grep iptables

      查看防火墙状态:

    service iptables status  OR  /etc/init.d/iptables status

      临时关闭防火墙:

    service iptables stop  OR  /etc/init.d/iptables stop

      重启防火墙:

    service iptables restart  OR  /etc/init.d/iptables restart

      启动防火墙:

    service iptables start  OR  /etc/init.d/iptables start 

      永久关闭防火墙:

    chkconfig iptables off 

      永久关闭后启用:

    chkconfig iptables on

    centos 7:[centos7.0默认使用firewall作为防火墙]

    firewall

      查看默认防火墙状态:(关闭后显示notrunning,开启后显示running)

    firewall-cmd --state

      查看已经开放的端口:

    firewall-cmd --list-ports

      开启端口:

    firewall-cmd --zone=public --add-port=80/tcp --permanent
    
    命令含义: 
    –zone #作用域 
    –add-port=80/tcp #添加端口,格式为:端口/通讯协议 
    –permanent #永久生效,没有此参数重启后失效

      重启防火墙:

    firewall-cmd --reload #重启firewall

    systemctl:

      查看防火墙状态:

    systemctl list-unit-files|grep firewalld.service             #disabled防火墙处于关闭状态
    
    OR
    
    systemctl status firewalld.service                           #dead防火墙处于关闭状态

      停止firewall:

    systemctl stop firewalld.service

      启动firewall:

    systemctl start firewalld.service

      重启firewall:

    systemctl restart firewalld.service

      开机启动firewall:

    systemctl enable firewalld.service

      禁止firewall开机启动:

    systemctl disable firewalld.service

      查看firewall是否开机启动:

    systemctl is-enabled firewalld.service;echo $?

      

      

      

  • 相关阅读:
    2017.10.04
    2017.10.03
    Luogu P3110 [USACO14DEC]驮运Piggy Back
    Luogu P2176 [USACO14FEB]路障Roadblock
    Luogu P3797 妖梦斩木棒
    数列分块入门1-9 By hzwer
    CodeForces 【20C】Dijkstra?
    Luogu P2835 刻录光盘
    Luogu P1692 部落卫队
    Luogu P2847 [USACO20DEC]Moocast(gold)奶牛广播-金
  • 原文地址:https://www.cnblogs.com/rays-/p/8258752.html
Copyright © 2011-2022 走看看