zoukankan      html  css  js  c++  java
  • Linux实战案例(5)关闭Centos的防火墙

    1、检查防火墙的状态

    [root@LxfN1 ~]# service iptables status
    表格:filter
    Chain INPUT (policy ACCEPT)
    num target prot opt source destination

    Chain FORWARD (policy ACCEPT)
    num target prot opt source destination
    1 DOCKER all -- 0.0.0.0/0 0.0.0.0/0
    2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
    3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
    4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0

    Chain OUTPUT (policy ACCEPT)
    num target prot opt source destination

    Chain DOCKER (1 references)
    num target prot opt source destination

    表格:nat
    Chain PREROUTING (policy ACCEPT)
    num target prot opt source destination
    1 DOCKER all -- 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL

    Chain INPUT (policy ACCEPT)
    num target prot opt source destination

    Chain OUTPUT (policy ACCEPT)
    num target prot opt source destination
    1 DOCKER all -- 0.0.0.0/0 !127.0.0.0/8 ADDRTYPE match dst-type LOCAL

    Chain POSTROUTING (policy ACCEPT)
    num target prot opt source destination
    1 MASQUERADE all -- 172.17.0.0/16 0.0.0.0/0

    Chain DOCKER (2 references)
    num target prot opt source destination

    2、以管理员身份关闭防火墙

    [root@LxfN1 ~]# service iptables stop
    iptables:将链设置为政策 ACCEPT:filter nat [确定]
    iptables:清除防火墙规则: [确定]
    iptables:正在卸载模块: [确定]

    3、检查防火墙是否运行中

    [root@LxfN1 ~]# service iptables status
    iptables:未运行防火墙。

    4、永久关闭防火墙

    [root@LxfN1 ~]# chkconfig iptables off

    5、关闭selinux

    vi /etc/selinux/config

    将SELINUX=enforcing改为SELINUX=disabled
    需要重启机器生效!

    CentOS 6:

    1) 永久性生效,重启后不会复原

    开启: chkconfig iptables on

    关闭: chkconfig iptables off

    2) 即时生效,重启后复原

    开启: service iptables start

    关闭: service iptables stop

    CentOS 7:

    systemctl start firewalld.service#启动firewall
    systemctl stop firewalld.service#停止firewall
    systemctl disable firewalld.service#禁止firewall开机启动

    查询TCP连接情况:

     netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

    查询端口占用情况:

     netstat   -anp   |   grep  portno(例如:netstat –apn | grep 80)

  • 相关阅读:
    片段
    告诉长夜
    明天
    开源一个WEB版本GEF,基于SVG的网页流程图框架
    RCP:ISourceLocator翻译
    SVG:textPath深入理解
    SVG:linearGradient渐变在直线上失效的问题解决方案
    【半平面交】BZOJ2618[Cqoi2006]凸多边形
    【旋转卡壳+凸包】BZOJ1185:[HNOI2007]最小矩形覆盖
    【凸包+旋转卡壳】平面最远点对
  • 原文地址:https://www.cnblogs.com/lexiaofei/p/6757352.html
Copyright © 2011-2022 走看看