zoukankan      html  css  js  c++  java
  • 13、单机运行环境搭建之 --Centos6.4下iptables保护主机安全

    编辑/etc/rc.local 输入如下内容:

    #!/bin/sh
    #
    # This script will be executed *after* all the other init scripts.
    # You can put your own initialization stuff in here if you don't
    # want to do the full Sys V style init stuff.
    touch /var/lock/subsys/local
    #启动memcached
    /usr/local/bin/memcached -d -m 1024 -u root -p 11211 -c 256 -P /tmp/memcached.pid
    
    #配置防火墙
    /sbin/iptables -F
    /sbin/iptables -X
    /sbin/iptables -Z
    /sbin/modprobe ip_tables
    /sbin/modprobe iptable_nat
    /sbin/modprobe ip_nat_ftp
    #/sbin/modprobe ip_conntrack
    /sbin/iptables -P INPUT DROP
    /sbin/iptables -P FORWARD ACCEPT
    /sbin/iptables -P OUTPUT ACCEPT
    
    #每秒钟最多允许100个新连接
    /sbin/iptables -A INPUT -f -m limit --limit 100/sec --limit-burst 100 -j ACCEPT
    #防止ping洪水攻击,限制每秒的ping包不超过10个
    /sbin/iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s --limit-burst 10 -j ACCEPT
    #防止各种端口扫描,将SYN及ACK SYN限制为每秒钟不超过200个,免得把数务器带宽耗尽了
    /sbin/iptables -A INPUT -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -m limit --limit 20/sec --limit-burst 200 -j ACCEPT
    #放开指定主机的访问,比如是入侵检测的主机IP
    #/sbin/iptables -A INPUT -s 122.70.x.x -j ACCEPT
    #回路数据当然需要放开了
    /sbin/iptables -A INPUT -i lo -j ACCEPT
    /sbin/iptables -A OUTPUT -o lo -j ACCEPT
    #自已发的自己可以收
    /sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    #开放80与22端口,不解释
    /sbin/iptables -A INPUT -p tcp -m multiport --dport 80,22 -j ACCEPT
    
    
    如果在测试中发现不能自动运行,就需要创建一个软链接了:
    ln -s /etc/rc.local /etc/rc3.d/S99rc.local
  • 相关阅读:
    防抖节流函数
    富文本编辑器tinymce在vue中的使用
    vue脚手架中检测lodop安装情况
    打印插件LODOP Vue中的使用
    vue打包后刷新页面报错:Unexpected token <
    Bootstrap-table表格插件的使用方法
    jsTree树插件
    Vue监控器watch的全面解析
    Vue计算属性computed的全面解析
    基于JQuery可拖动列表格插件DataTables的踩坑记
  • 原文地址:https://www.cnblogs.com/littlehb/p/3016094.html
Copyright © 2011-2022 走看看