zoukankan      html  css  js  c++  java
  • CentOS7.2 切换成iptables规则

    关闭firewall

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

    安装iptables规则:

    yum install iptables-services #安装

    打开/etc/sysconfig/iptables配置文件

    默认:

    # sample configuration for iptables service
    # you can edit this manually or use system-config-firewall
    # please do not ask us to add additional ports/services to this default configuration
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
    -A INPUT -p icmp -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
    -A INPUT -j REJECT --reject-with icmp-host-prohibited
    -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    COMMIT

    修改成:

    # sample configuration for iptables service
    # you can edit this manually or use system-config-firewall
    # please do not ask us to add additional ports/services to this default configuration
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
    -A INPUT -p icmp -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
    -A INPUT -j REJECT --reject-with icmp-host-prohibited
    -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    COMMIT

    添加了80,8080

    service iptables start #开启
    systemctl enable iptables.service #设置防火墙开机启动

    基本操作:

    service iptables status      #查看iptables状态
    service iptables restart     #iptables服务重启
    service iptables stop         #iptables服务禁用 

    http://blog.csdn.net/xlgen157387/article/details/52672988

  • 相关阅读:
    2020.10.31
    2020.10.26
    2020.10.29
    2020.10.28动手动脑+验证
    2020.11.1(每周学习总结)
    2020.10.30
    2020.11.2动手动脑➕课后试验性问题
    Javascript权威指南阅读笔记第3章类型、值和变量(1)
    【一个小功能】从js判断ie版本,浅谈navigator对象的appName属性
    【Vue】vif与vshow的区别
  • 原文地址:https://www.cnblogs.com/hongdada/p/6683219.html
Copyright © 2011-2022 走看看