通过以下 Referral 链接购买 DigitalOcean 主机,你将可以帮助 V2EX 持续发展
DigitalOcean - SSD Cloud Servers
barb
V2EX  ›  VPS

有什么好的防止 DO 上的 VPS 被流量爆仓的办法

  •  
  •   barb · Feb 6, 2016 · 963 views
    This topic created in 3837 days ago, the information mentioned may be changed or developed.

    也有可能是被人入侵了,一下子流量飙到很高,被 DO 管理员叫停,有什么控制的办法吗

    2 replies    2016-02-06 16:01:45 +08:00
    datocp
        1
    datocp  
       Feb 6, 2016   ❤️ 1
    最简单的就是设置一个每天限值 OUTPUT 方向的流量 40Gbytes ,每天用 cron 任务在 17:01 清空计数一次。效果是有的,但不知道对 ddos 的效果。。。

    # iptables -S quota40g
    -N quota40g
    -A quota40g -m quota --quota 42163708297 -j RETURN
    -A quota40g -j DROP
    # iptables -S OUTPUT
    -P OUTPUT ACCEPT
    -A OUTPUT -j quota40g

    cron 任务 1 17 * * * /path/reset.sh
    /path/reset.sh
    --------------------------------------------------
    #!/bin/sh
    PATH=/bin:/usr/bin:/sbin:/usr/sbin

    if [ $(date +"%H%M") = 1701 ];then

    #计数清零
    iptables -Z quota40g

    echo "`(date +"%m/%d/%Y %T")` iptables_quota clear successfully_" >> /tmp/log
    fi
    --------------------------------------------------
    New2016
        2
    New2016  
       Feb 6, 2016 via iPhone
    关机
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2915 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 08:24 · PVG 16:24 · LAX 01:24 · JFK 04:24
    ♥ Do have faith in what you're doing.