• 常用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.
     
     
     
     
     
     
     
     
  • 相关阅读:
    top命令
    MySQL基准测试(三)--开源工具与实例演示
    MySQLdump之single-transaction详解
    牛刀小试MySQL--日志文件
    MySQL基准测试(二)--方法
    MySQL基准测试(一)--原因,策略,思路
    MySQL实验准备(二)--Python模拟数据(MySQL数据库)
    MySQL实验准备(一)--环境准备
    InnoDB存储引擎概览
    单机多实例mysq 8.0l部署安装
  • 原文地址:https://www.cnblogs.com/TaleG/p/5352303.html
Copyright © 2020-2023  润新知