zoukankan      html  css  js  c++  java
  • 常用iptables规则整理

    1、仅允许内部合法的IP地址访问服务器

    #setting access rules
    #one,in access rules,allow all the ips of hudong.com
    iptables -A INPUT -s 192.168.3.3/24 -p all -j ACCEPT
    iptables -A INPUT -s 192.168.4.4/24 -p all -j ACCEPT
    ........
     
    2、仅允许内部合法IP段访问监控服务nagios
    #second,port access rules
    #nagios
    iptables -A INPUT -s 192.168.1.0/24 -p tcp --dport 5666 -j ACCEPT
    .......
     
    3、仅允许内部合法的IP段访问Mysql和ORACLE数据库
    iptables -A INPUT -s 192.168.4.4/24 -p tcp --dport 3306 -j ACCEPT
    ........
     
    4、仅允许内部合法的IP段访问SSH远程连接服务
    #ssh difference form other servers hers
    iptables -A INPUT -p tcp -s 192.168.1.0/24 --dport 45215 -j ACCEPT
    ......
    (注意:SSH端口最好改为其他端口。还有,最好只让内部网络可以连接)
     
    5、对HTTP服务的不同限制
    a、对外提供HTTP服务的业务,要允许HTTP服务通过,并且不限制IP。
    #http
    iptables -A INPUT -p tcp --dport 80 -j ACCEPT
    .......
    b、对内提供HTTP服务的业务,一般用特殊端口,并且限制合法IP连接或VPN连接。
    iptables -A INPUT -s 192.168.1.0/24 -p tcp -m multiport --dport 8080,8081,8082,8888 -j ACCEPT
    ........
    5、SNMP的限制
    #snmp
    iptables -A INPUT -s 192.168.1.0/24 -p UDP --dport 161 -j ACCEPT
    ......
     
    6、rsync服务的限制策略
    #rsync
    iptables -A INPUT -s 192.168.1.0/24 -p tcp -m tcp --dport 873 -j ACCEPT
    .......
     
    7、ftp服务限制
    #others RELATED
    #ftp
    #iptables -A INPUT -p tcp --dport 20:21 -j ACCEPT(这里不兴允许21端口,也要允许20号端口)
    iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    说明:
    iptables -A INPUT -m state --state 状态 -j ACCEPT
    state
        this module,when combined with connection tracking,allows access to the connection tracking state for this packet.
     
     
     
     
     
     
     
     
  • 相关阅读:
    C#调用C++ memcpy实现各种参数类型的内存拷贝 VS marshal.copy的实现 效率对比
    UGUI 事件穿透规则
    UGUI 锚点设置为四方扩充模式然后设置局部坐标为0将出现什么问题
    UNITY polygon collider不随物体旋转
    android Handler机制 消息机制
    java final finally finalize
    collection 和 collections
    java 不通过第三个字符串,实现一个字符串倒序
    ArrayList,Vector,LinkedList
    String StringBuffer stringbuilder 区别
  • 原文地址:https://www.cnblogs.com/TaleG/p/5352303.html
Copyright © 2011-2022 走看看