티스토리 뷰

Security

iptables connlimit and hashlimit

CHOMAN 2015. 6. 10. 13:58
connlimit

       Allows you to restrict the number of parallel connections to a server per client IP address (or client address block).
       각 클라이언트 IP당 병렬연결의 수를 제한할수 있다? 
       각 소스아이피를 하나하나 일일이 제어(매칭)가능하다라는 의미일듯        

       [!] --connlimit-above n
              Match if the number of existing connections is (not) above n.
              n개수만큼의 접근의 시도를 매칭 
              초당 몇개 이상 접속시도가 들어오면 어떻게 하라나는식으로 매칭이 가능하다라는 의미일듯

       --connlimit-mask prefix_length
              Group hosts using the prefix length. For IPv4, this must be a number between (including) 0 and 32. For IPv6, between 0 and 128.
              아이피 그룹을 지을수 있다 ipv4의 경우 0~32 , ipv6의 경우 0~128, 네트워크주소로도 처리할수 있다는 의미일듯 (서브넷팅을 의미하는듯 함)

ex)  3306으로 초당 100회 이상 접속시도가 이루어 지면 test 라는 이름으로 저장하고 300초 동안 드랍
-A INPUT -p tcp --dport 3306 -m recent --name test --rcheck --seconds 300 -j DROP
-A INPUT -p tcp --dport 3306 -m connlimit --connlimit-above 100 -m recent --name test --set -j DROP

-A INPUT -p tcp --dport 3306 -m connlimit --connlimit-above 100 -j DROP 



conntrack 모듈이 올라오므로 DDOS 공격이 대량 들어오면 버티지 못할듯 함

lsmod


nf_conntrack_ipv4       9506  1

nf_defrag_ipv4          1483  1 nf_conntrack_ipv4

xt_connlimit            3238  1

nf_conntrack           79645  2 nf_conntrack_ipv4,xt_connlimit



hashlimit
       hashlimit  uses  hash  buckets  to  express a rate limiting match (like the limit match) for a group of connections using a single iptables rule. 
       connlimit 와 유사하나 해쉬버킷을 이용하여 매칭 및 표현한다?


Grouping can be done per-hostgroup

       (source and/or destination address) and/or per-port. It gives you the ability to express "N packets per time quantum per group":


ex) 80번 포트로 초당 100회까지 허용 그 이상 오버되는 패킷은 차단

 -A INPUT -p tcp --dport 80 -m hashlimit --hashlimit-mode srcip,dstport --hashlimit-name tcp

--hashlimit 100/s --hashlimit-burst 100 -j RETURN

-A INPUT -p tcp --dport 80 -j DROP



매칭되는 아이피 정보는 아래 명령어로 확인



cat /proc/net/ipt_hashlimit/tcp


'Security' 카테고리의 다른 글

nftables 설치 (with Centos7)  (2) 2015.06.10
nftables 기본 개념 문법 간단 정리  (0) 2015.06.10
Linux 계열 취약성 점검 체크 리스트  (0) 2015.06.09
기업 소프트웨어 라이센스 정리  (0) 2015.06.09
보안점검 툴  (0) 2015.06.09
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함