on
apache DDOS 방지 모듈 - MOD_EVASIVE
apache DDOS 방지 모듈 - MOD_EVASIVE
yum -y update
(필요하다면)
yum -y install epel-release
설치
yum -y install mod_evasive
설정파일 편집 (주석해제 및 수치 변경)
vi /etc/httpd/conf.d/mod_evasive.conf
# mod_evasive configuration LoadModule evasive20_module modules/mod_evasive24.so # The hash table size defines the number of top-level nodes for each child's hash table. Increasing this number will provide faster performance by decreasing the number of iterations required to get to the record, but consume more memory for table space. You should increase this if you have a busy web server. The value you specify will automatically be tiered up to the next prime number in the primes list (see mod_evasive.c for a list of primes used). DOSHashTableSize 3097 # This is the threshhold for the number of requests for the same page (or URI) per page interval. Once the threshhold for that interval has been exceeded, the IP address of the client will be added to the blocking list. DOSPageCount 10 # This is the threshhold for the total number of requests for any object by the same client on the same listener per site interval. Once the threshhold for that interval has been exceeded, the IP address of the client will be added to the blocking list. DOSSiteCount 20 # The interval for the page count threshhold; defaults to 1 second intervals. DOSPageInterval 10 # The interval for the site count threshhold; defaults to 1 second intervals. DOSSiteInterval 10 # The blocking period is the amount of time (in seconds) that a client will be blocked for if they are added to the blocking list. During this time, all subsequent requests from the client will result in a 403 (Forbidden) and the timer being reset (e.g. another 10 seconds). Since the timer is reset for every subsequent request, it is not necessary to have a long blocking period; in the event of a DoS attack, this timer will keep getting reset. DOSBlockingPeriod 60 # If this value is set, an email will be sent to the address specified whenever an IP address becomes blacklisted. A locking mechanism using /tmp prevents continuous emails from being sent. # # NOTE: Requires /bin/mail (provided by mailx) DOSEmailNotify 이메일@gmail.com # If this value is set, the system command specified will be executed whenever an IP address becomes blacklisted. This is designed to enable system calls to ip filter or other tools. A locking mechanism using /tmp prevents continuous system calls. Use %s to denote the IP address of the blacklisted IP. #DOSSystemCommand "su - someuser -c '/sbin/... %s ...'" # Choose an alternative temp directory By default "/tmp" will be used for locking mechanism, which opens some security issues if your system is open to shell users. # # http://security.lss.hr/index.php?page=details&ID;=LSS-2005-01-01 # # In the event you have nonprivileged shell users, you'll want to create a directory writable only to the user Apache is running as (usually root), then set this in your httpd.conf. DOSLogDir "/var/log/mod_evasive.log" # You can use whitelists to disable the module for certain ranges of IPs. Wildcards can be used on up to the last 3 octets if necessary. Multiple DOSWhitelist commands may be used in the configuration. #DOSWhitelist 127.0.0.1 #DOSWhitelist 192.168.0.*
(1) DOSHashTableSize
DOSHashTableSize 3097
해시 테이블 메모리 크기
접속이 많으면 수치를 올림
================================================
(2) DOSPageCount
DOSPageCount 10
지정된 시간동안(DOSPageInterval) 같은 페이지를 지정된 수 보다 초과 요청을 할 경우
IP 정보가 블러킹 리스트에 추가된다.
(3) DOSPageInterval
DOSPageInterval 10
페이지 요청 제한시간(초) - (2)번과 (3)번을 적용하면, 10초간 10번 이상 같은 IP에서 호출하면 해당 IP를 블로킹.
================================================
(4) DOSSiteCount
DOSSiteCount 20
지정된 시간동안(DOSSiteInterval) 같은 사이트를 지정된 수 보다 초과 요청을 할 경우
IP 정보가 블러킹 리스트에 추가된다.
(5) DOSSiteInterval
DOSSiteInterval 30
사이트 요청 제한시간(초) - (4)번과 (5)번을 적용하면, 30초간 20번 이상 같은 IP에서 호출하면 해당 IP를 블로킹.
================================================
(6) DOSBlockingPeriod
DOSBlockingPeriod 60
클라이언트가 블랙리스트에 추가되어 블러킹되는 총 시간. 이때 클라이언트는 403 (Forbidden) 에러를 출력
(7) DOSEmailNotify
DOSEmailNotify 이메일@gmail.com
IP가 블러킹 될 때 이메일로 전송
메일러는 mod_dosevasive.c 에 정확하게 지정되야 한다. 디폴트는 "/bin/mail -t %s" 이다.
(8) DOSLogDir
DOSLogDir "/var/log/mod_evasive.log"
로그파일 생성
$ touch /var/log/mod_evasive.log
파일 쓰기 권한이 있어야 함
(9) DOSSystemCommand
DOSSystemCommand "실행명령"
아이피가 블록될 때 실행 명령 (옵션사항)
%s로 차단 아이피 문자를 사용 할 수 있음.
(10) DOSWhitelist
DOSWhitelist 127.0.0.1 DOSWhitelist 192.168.0.*
차단에서 제외될 호스트 등록
from http://devlink.tistory.com/662 by ccl(A) rewrite - 2021-10-25 15:00:37