精華區beta Linux 關於我們 聯絡資訊
阿里巴巴 撰寫於文章 <3Tk1Il$Hvw@bbs.cm.nctu.edu.tw>... >我遇到的情況是: >某個 domain 的幾個 host 不斷來 access, 幾乎達到 >每秒鐘一次, 而且會重覆 access 同樣幾個頁面, 連續 >很多天了, 測了一下, 那幾個 host 應該都是跑 robot, >猜想是對方的 robot 出問題了, 因為一般正常 robot >也不致於這麼暴力. >在 apache 是可以用 access.conf 來 deny 掉對方的 >access, 但是仍會在 access_log 及 error_log 紀錄 >下一堆垃圾. >結果這兩個 log 檔就暴增, 一小時大約有 800K. >想改用 /etc/hosts.deny 來拒絕, 例如: >ALL: .bad_domain.com >但要如何與 /etc/inetd.conf 搭配呢﹖它的格式是: ><service_name> <sock_type> <proto> <flags> <user> <server_path> <args> >該怎麼寫﹖把它完全擋掉, 不去 access apache 而留下一堆 log 垃圾. 把 httpd 改成 inetd 的方式啟動,擋某個 ip 的部分,就使用 tcp_wrappers 的設定方式,在 hosts.deny ban 掉應該就可以了. 首先把當務之急就是把 httpd 改成 inetd 方式啟動,所以要修改 httpd.conf 檔案內的 ServerType 敘述,把 ServerType standalone 改成 ServerType inetd . 接著修改 inetd.conf 檔案的設定,新增 http 的服務項目: http stream tcp nowait root /usr/sbin/tcpd httpd 這樣 httpd 就可以透過 inetd 來啟動. 要 ban 掉某個 ip 的部分,再修改 hosts.deny 的敘述,比方 httpd : xxx.xxx.xxx.xxx 這樣這個 ip 位置的主機就無法使用 http 的服務,應該也不會留下 太多的 log 紀錄檔案 :-) -- 真情最可貴 用心最踏實 --