Recommended Services
› Amazon Web Services
› LeanCloud
› New Relic
› ClearDB
ru20150601
V2EX  ›  云计算

服务器流量被刷爆,怎么看日志找出原因?

  •  
  •   ru20150601 · Oct 28, 2015 · 10118 views
  •   You need to sign in to view this topic
    This topic created in 4022 days ago, the information mentioned may be changed or developed.
    各位大哥,,小弟我的 ss 香港共享服务器, 21 号刚重置的流量,今天发现被人刷爆流量了。由于我使用的 ss 都限制的流量,并且密码都很复杂。应该不是这个服务被人刷爆的。可能是被人破解了登录密码或者被人发了垃圾邮件。请问我现在应该如何找出原因呢?
    20 replies  •  2015-10-30 16:54:20 +08:00
    yech1990
        1
    yech1990  
       Oct 28, 2015
    cd /var/log
    aivier
        2
    aivier  
       Oct 28, 2015
    不要共享。
    重要的事不能说三遍
    ru20150601
        3
    ru20150601  
    OP
       Oct 28, 2015
    @yech1990
    @aivier
    谢谢两位的回复。我的不是共享,就是分给朋友用的,,然后要么就是朋友的朋友。。。。不是完全公开的。。。我自己搞的,什么都不懂,完全按照网上的教程来的。。。
    onlyxuyang
        4
    onlyxuyang  
       Oct 28, 2015 via Android
    把密码登录关掉 只允许 rsa 登录 再狠点就锁 ip '只有指定 ip 可以登录
    wdlth
        5
    wdlth  
       Oct 28, 2015
    那么这 7 天你都没有看流量么?还是说流量是今天爆的?
    msg7086
        6
    msg7086  
       Oct 28, 2015
    开 iftop 先看看是哪个端口哔了 poi 。
    ixiaohei
        7
    ixiaohei  
       Oct 28, 2015
    能请问你的香港 vps 哪家的么?我也想买个香港 vps
    fashioncj
        8
    fashioncj  
       Oct 28, 2015
    直接看 ss 的日志。。里面应该有详细的记录的
    selinaspy
        9
    selinaspy  
       Oct 29, 2015 via iPad
    用 iptables 监控端口流量,妥妥的
    kmahyyg
        10
    kmahyyg  
       Oct 29, 2015
    @selinaspy 怎么设置 我用的 firewalld
    odirus
        11
    odirus  
       Oct 29, 2015
    ss 里面有日志
    trepwq
        12
    trepwq  
       Oct 29, 2015 via iPhone
    @ixiaohei 域名 host 开头的两个都有,反正我用着还可以
    bjzhush
        13
    bjzhush  
       Oct 29, 2015
    我的 linode 的 vps 开了 ss,小范围共享了下,你多少流量被刷掉了? 我一月 2T 流量,除非有人拿服务器跟我对刷,其它的并不担心
    cppgohan
        14
    cppgohan  
       Oct 29, 2015
    这种问题, 有什么方式可以预防吗? 防患于未然?
    icegreen
        16
    icegreen  
       Oct 29, 2015
    DO...不限流......
    datocp
        17
    datocp  
       Oct 29, 2015   ❤️ 1
    嘿嘿,在准备共享时就考虑过这个问题。

    第一种就是通过 hashlimi 限制并发,但是限制并发一直是一种不好的方法,不建议,除非服务器有并发限制。下面的方法可以让 wget 由 40MB/s 下降到 500kb/s-1MB/s 左右。这样就浪费爆破的人的时间。。。


    ##-A INPUT -p tcp -m multiport --dport 80,1723,8080,8443,8843 -d xxx.62.112.147 -m hashlimit --hashlimit-name obfs --hashlimit 80/sec --hashlimit-burst 350 --hashlimit-mode srcip,srcport --hashlimit-htable-expire 300000 -j ACCEPT
    ##-A INPUT -p tcp -m multiport --dport 80,1723,8080,8443,8843 -d xxx.62.112.147 -j REJECT

    =================
    使用 iptables recent quota 每天对每 ip 流量进行限制。

    预先在 iptables INPUT 获得访问用户的源 ip
    iptables -I INPUT -p tcp -m multiport --dport 80,443,1723,8080,8443,8843 -d xxx.62.112.147 -m recent --name squota --rsource --set

    然后用 cron 每 5 分钟调度 quota.sh
    */5 * * * * /tmp/quota.sh

    在每天的 1701 点去除所有限制
    根据 squota 列表获得源 ip 限制每个 ip 可以使用 2Gbytes 流量,但是用户可以通过更换 ip 继续获得 2Gbytes 流量
    新建一个 quota40g 表用于计数用途,当天用完 40Gbytes 流量,服务器 DROP 所有的访问。

    #/bin/sh

    perip_traffic=2147483648 #2Gbytes

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

    total_traffic=42949672960 #40Gbytes

    #建立每天总流量 40G 限制
    iptables -N quota40g
    iptables -F quota40g #iptables -Z quota40g
    iptables -Z OUTPUT
    iptables -A quota40g -m quota --quota $total_traffic -j ACCEPT
    iptables -A quota40g -j DROP

    #去除过期限制
    echo / >/proc/net/xt_recent/squota
    echo / >/proc/net/xt_recent/bquota
    echo "`(date +"%m/%d/%Y %T")` iptables_quota clear successfully_" >> /tmp/log
    fi

    #排除非限制 IP
    echo -XXX.62.112.147 >/proc/net/xt_recent/squota
    echo -XXX.78.0.25 >/proc/net/xt_recent/squota

    #根据源 ip 列表做匹配添加每 ip 限制操作
    cat /proc/net/xt_recent/squota|awk '{print $1}' |awk -F"=" '{print $2}'|awk '!i[$1]++'>/tmp/squota.tmp
    iptables -S OUTPUT>/tmp/iptables.quota
    for i in `cat /tmp/squota.tmp`;
    do grep -q $i /tmp/iptables.quota
    if [ $? -gt 0 ];then

    #注意顺序不然可能会导致立刻 quota 又被立刻 unquota
    iptables -I OUTPUT -o venet0 -d $i -m quota --quota $perip_traffic -j quota40g
    iptables -A OUTPUT -o venet0 -d $i -m recent --name bquota --rdest --set
    iptables -A OUTPUT -o venet0 -d $i -j REJECT

    echo "`(date +"%m/%d/%Y %T")` iptables_quota $i successfully_" >> /tmp/log
    fi;done
    datocp
        18
    datocp  
       Oct 29, 2015
    脚本开头可能要这样,不然 cron 下面执行有问题,debian 8 下面没问题。


    #/bin/sh
    PATH=/bin:/usr/bin:/sbin:/usr/sbin

    perip_traffic=2147483648 #2Gbytes
    akira
        19
    akira  
       Oct 29, 2015
    @ru20150601 只要你给了朋友,就别指望别人不会拿来看各种视频
    ru20150601
        20
    ru20150601  
    OP
       Oct 30, 2015
    各位各位!谢谢大家热情回复!但是我强调一点。。。这个流量不是 SS 走的!

    我的 SS 有流量统计,并且都有限制的。一旦超过了预定流量,会自动关闭的!没有任何问题!我说的流量被刷爆,是有人恶意用其他的方式走掉了我的 vps 流量。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2684 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 67ms · UTC 13:54 · PVG 21:54 · LAX 05:54 · JFK 08:54
    ♥ Do have faith in what you're doing.