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.
     
     
     
     
     
     
     
     
  • 相关阅读:
    物联网操作系统HelloX V1.77(beta)版本发布
    对XX证券报关于物联网操作系统的几个问题的答复
    Android利用广播实现ViewPager中item之间的数据通信
    Android创建桌面快捷方式
    Android时间选择器对话框的使用
    Android数据库LitePal的存储操作
    Android创建数据表和LitePal的基本用法
    我的2014
    logstash 安装zabbix插件
    tag_on_failure => [] # prevent default _grokparsefailure tag on real records
  • 原文地址:https://www.cnblogs.com/TaleG/p/5352303.html
Copyright © 2011-2022 走看看