關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • 檢查 IP 連線數量及封鎖 IP

    Posted on October 2nd, 2008 Sam Tang 4 comments

    以下是幾條有用的指令,檢查 IP 連線數量及封鎖 IP

    iptables -A INPUT -p all -s IPHERE/32 -j DROP

    封鎖 IP

    iptables -D INPUT -p all -s IPHERE/32 -j DROP

    解除封鎖 IP

    netstat -atnp -A inet | grep ":80" | awk -F " " '{print $5} ' | awk -F ":" '{print $1}' | sort | uniq -c | sort -nr | head -5

    列出最多連接數的 5 個 IP 及其連接數,其中 ":80" 是連接埠號,可改成想要檢查的埠號。

    netstat -nap | grep ESTABLISHED | wc -l
    netstat -nap | grep SYN | wc -l
    netstat -nap | grep TIME_WAIT | wc -l

    以上 3 個指令可以列出總連線數目。


     

    4 responses to “檢查 IP 連線數量及封鎖 IP”

    1. good, ^_^

    2. 說的有道理,資訊透明化。

    3. 嗯,還不錯啦。

    4. 你好,我在查一些php、netstat的資料的時候找到了你的網站,
      不知道可否向你請教,有沒有可能用php取得Client端的所有連線?

      即 A連到B,而B想知道A的所有net stat.

      請問這有可能以php實現嗎?

    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word