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)

  • 相关阅读:
    BZOJ 1854: [Scoi2010]游戏( 二分图最大匹配 )
    BZOJ 2038: [2009国家集训队]小Z的袜子(hose) ( 莫队 )
    BZOJ 3555: [Ctsc2014]企鹅QQ( hash )
    BZOJ 2226: [Spoj 5971] LCMSum( 数论 )
    BZOJ 3505: [Cqoi2014]数三角形( 组合数 )
    BZOJ 2510: 弱题( 矩阵快速幂 )
    BZOJ 1009: [HNOI2008]GT考试( dp + 矩阵快速幂 + kmp )
    BZOJ 1090: [SCOI2003]字符串折叠( 区间dp )
    HDU 2295 Radar dancing links 重复覆盖
    ZOJ 3209 Treasure Map dancing links
  • 原文地址:https://www.cnblogs.com/lexiaofei/p/6757352.html
Copyright © 2011-2022 走看看