Domain, hosting, vps giá rẻ
Kết quả 1 đến 4 của 4

Chủ đề: [Linux Centos] Tối ưu server : Anti DDos cho Linux Webserver

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    nghiammo1992's Avatar
    Bài viết
    5,075
    Cấp độ
    Bang hội
    Tiếu Ngạo
    Tu luyện
    Độ kiếp Hư Thần
    Giới tính
    Con trai
    Join Date
    Jun 2012
    Đến từ
    Hà Giang
    Tuổi
    32
    Danh vọng
    10
    Điện thoại
    0367790762

    [Linux Centos] Tối ưu server : Anti DDos cho Linux Webserver

    Nói về vấn đề DDos, có lẽ sẽ rất khó để chắc chắn rằng làm thế nào chúng ta có thể an toàn 100% trước vấn nạn này. Bởi có rất nhiều phương thức tấn công như dos,ddos, flood, Slowloris …cũng như đi kèm với nó là các cường độ khác nhau. Bởi vậy các giải pháp TechBlog trình bày bên dưới sẽ chỉ có thể giúp bạn trong một số trường hợp nhất định mà thôi. Tuy vậy nó cũng sẽ phần nào giúp bạn kiện toàn bảo mật cho webserver của bạn.







    1. Hạn chế DDos: Dos Deflate


    Tiến hành cài đặt Firewall Dos Deflate:
    #cd download
    #wget http://www.inetbase.com/scripts/ddos/install.sh
    #chmod 0700 install.sh
    #./install.sh
    Sau khi cài đặt thành công, ta có thể cấu hình Firewall bằng cách dùng lệnh:
    #nano /user/local/ddos/ddos.conf
    Đây là file cấu hình của Firewall, nội dung cơ bản sẽ như sau:
    FREQ=1 // tắt/ bật Firewall (0=tắt, 1=bật)
    NO_OF_CONNECTIONS=150 // max connect từ 1 IP đến server
    APF_BAN=1
    KILL=1 // tắt/bật (0=tắt, 1= bật)
    EMAIL_TO="administrator@techblog.vn"
    BAN_PERIOD=600 // thời gian ban IP là 600 giây

    Khởi động:
    Mã:
    /usr/local/ddos/ddos.sh -c
    Cấu hình khởi động cùng hệ thồng:

    Mã:
    ## Edit /etc/rc.d/rc.local 
    ##      (or similar file depending on Linux version) 
    ## Add the following lines at the bottom of the file  
    
    /usr/local/ddos/ddos.sh -c
    2. Apache Antiddos Mod: mod_dosevasive

    Refer to the following steps to install the Mod_evasive but make sure that you have logged in as a root user.


    cd /usr/local/src
    wget http://theperfectarts.com/software/m..._1.10.1.tar.gz
    tar xvfz mod_ev*
    cd mod_evasive*


    Tiếp tục đánh lệnh sau:

    apxs -cia mod_evasive20.c

    Nếu xuất hiện lỗi như sau -bash: apxs: command not found thì do các bạn chưa cài apxs

    yum install httpd-devel (yum install apache2-threaded-dev gcc)

    Tìm và thêm vào file httpd.conf đoạn sau:
    Add the following to httpd.conf


    <IfModule mod_dosevasive20.c> DOSHashTableSize 3097
    DOSPageCount 1
    DOSSiteCount 50
    DOSPageInterval 1
    DOSSiteInterval 1
    DOSBlockingPeriod 10
    DOSEmailNotify root
    # DOSSystemCommand “su – someuser -c ‘/sbin/… %s …’”
    # DOSLogDir “/var/tmp/doslog”
    #Leave this commented while testing, then uncomment once you are sure the module works
    # DOSWhitelist 127.0.0.1
    </IfModule>

    hoặc

    <IfModule mod_dosevasive20.c>
    DOSHashTableSize 3097
    DOSPageCount 6
    DOSSiteCount 100
    DOSPageInterval 2
    DOSSiteInterval 2
    DOSBlockingPeriod 600
    DOSEmailNotify someuser@somedomain.com
    </IfModule>




    Descriptions:

    - DOSHashTableSize: the size of the table of URL and IP combined
    - DOSPageCount: the number of same page requests from the same IP during an interval that will cause that IP to be added to the block lt.
    - DOSSiteCount: the number of pages requested of a site by the same IP during an interval which will cause the IP to be added to the block lt.
    - DOSPageInterval: the interval that the hash table for IPs and URLs erased (in seconds)
    - DOSSiteInterval: the intervale that the hash table of IPs erased (in seconds)
    - DOSBlockingPeriod: the time the IP blacked (in seconds)
    - DOSEmailNotify: can be used to notify by sending an email everytime an IP blocked
    - DOSSystemCommand: the command used to execute a command when an IP blocked. It can be used to add a block the user from a firewall or router.
    - DOSWhiteLt: can be used to whitelt IPs such as 127.0.0.1


    Sau đó lưu lại và restart apache bằng lệnh:
    #service httpd restart
    hoặc
    #/etc/init.d/httpd restart



    3. Cài đặt và cấu hình Iptables:

    iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 3 -j RETURN

    Về thông tin giới thiệu, cài đặt, cách sử dụng TechBlog đã có trình bày cụ thể tại bài viết Cấu hình Firewall Iptables trên CentOS / Redhat. Trong trường hợp anti ddos, chúng ta chỉ quan tâm một số rules cơ bản như sau:
    #Limit the number of incoming tcp connections
    #Interface 0 incoming syn-flood protection
    #iptables -N syn_flood
    #iptables -A INPUT -p tcp --syn -j syn_flood
    #iptables -A syn_flood -m limit --limit 1/s --limit-burst 3 -j RETURN
    #iptables -A syn_flood -j DROP



    4. Cài đặt mod_antiloris cho Apache:

    How To Install Mod_Antiloris?

    1) Download the installer from sourceforge and install

    a) cd /usr/local/src
    b) wget http://sourceforge.net/projects/mod-...r.bz2/download
    c) tar -xvjf mod_antiloris-0.4.tar.bz2
    d) cd mod_antiloris-*
    e) apxs -a -i -c mod_antiloris.c

    2) Now we have to restart apache

    service httpd restart

    3) How to check whether mod_antiloris loaded or not

    httpd -M | grep antiloris

    Note if you are using cpanel server then you have to run the below command to make sure new modification are updated into configuration system file

    /usr/local/cpanel/bin/apache_conf_distiller –update

    Now you can check if your Apache is protected from Slowloris Dos attack or not . Launch a slowloris attack and check Apache status page to see if its effecting it or not.

    - Mod antiloris default giới hạn 20 connections cho một Ip, bạn có thể tùy chỉnh bằng cách add vào httpd.conf
    vd:
    <IfModule antiloris_module>
    IPReadLimit 50
    </IfModule>


    Chúc bạn thành công.
    Lần sửa cuối bởi nghiammo1992, ngày 01/03/2013 lúc 16:06.
    Diễn đàn chia sẻ kiến thức điện thoại: http://chiase123.com
    Click vào Hiện ra để xem chữ ký của mình :X

Thông tin về chủ đề này

Users Browsing this Thread

Có 1 người đang xem chủ đề. (0 thành viên và 1 khách)

Các Chủ đề tương tự

  1. Trả lời: 0
    Bài viết cuối: 28/05/2014, 0:19
  2. hỏi về cấu hình VPS linux centos
    Bởi kemcoi trong diễn đàn VPS - Server
    Trả lời: 0
    Bài viết cuối: 01/10/2013, 21:41
  3. [VPS] Toàn bộ câu lệnh sử dụng trong Server Linux từ A – Z
    Bởi nghiammo1992 trong diễn đàn VPS - Server
    Trả lời: 2
    Bài viết cuối: 01/10/2013, 21:40
  4. Tối ưu server : Anti DDos cho Linux Webserver
    Bởi nghiammo1992 trong diễn đàn VPS - Server
    Trả lời: 1
    Bài viết cuối: 28/06/2013, 9:59
  5. [Linux] Giới hạn load CPU chống ddos, overload server
    Bởi nghiammo1992 trong diễn đàn VPS - Server
    Trả lời: 0
    Bài viết cuối: 22/05/2013, 16:28
  6. Chống DDOS khẩn cấp cho Linux, an toàn và hiệu quả nhất
    Bởi nghiammo1992 trong diễn đàn VPS - Server
    Trả lời: 0
    Bài viết cuối: 22/02/2013, 1:59
  7. Cấu hình firewall chống ddos trên linux
    Bởi nghiammo1992 trong diễn đàn VPS - Server
    Trả lời: 0
    Bài viết cuối: 20/12/2012, 17:13
  8. [VPS Linux] Hướng dẫn cài cPanel 11 & WHM trên VPS Linux
    Bởi nghiammo1992 trong diễn đàn PHP & MySQL
    Trả lời: 0
    Bài viết cuối: 01/10/2012, 20:13
  9. [VPS linux] Hướng dẫn cài cpanel Kloxo trên VPS linux Centos
    Bởi nghiammo1992 trong diễn đàn PHP & MySQL
    Trả lời: 0
    Bài viết cuối: 01/10/2012, 20:07
  10. [VPS linux] Hướng dẫn cài cpanel Direct Admin trên VPS linux Centos
    Bởi nghiammo1992 trong diễn đàn PHP & MySQL
    Trả lời: 0
    Bài viết cuối: 01/10/2012, 20:04

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •