How can I block a country from my sites?

Discussion in 'Site & Server Administration' started by indyonline, Sep 21, 2011.

  1. #1
    I have some loser from China that keeps trying to hack my server about 50-60 times a day, literally. Does anybody know of a way I can block China from my sites and servers? I would like to block the entire country from my main server if I can. I have a VPS account with hostgator if that helps or if anybody knows of a service or script that they have that would be awesome. I was wondering if it could be done with .htaccess but don't know how to do that, where to put the file and what to include in it. I would really like to block all Asian countries and Russia from my sites and servers if anybody can help that would be awesome.
    Thanks, Rob
     
    Solved! View solution.
    indyonline, Sep 21, 2011 IP
  2. browntwn

    browntwn Illustrious Member

    Messages:
    8,347
    Likes Received:
    848
    Best Answers:
    7
    Trophy Points:
    435
    #2
    http://www.countryipblocks.net/country-blocks/select-formats/
     
    browntwn, Sep 21, 2011 IP
    indyonline likes this.
  3. #3
    Install CSF firewall, in the configuration (usually found in /etc/csf/csf.conf) search for "CC_DENY" and add the 2-letter ISO country codes (comma separated) there such as "CN" for China, "RU" for Russia, etc...save and restart CSF and there you go :)

    Personally I would avoid loading up too many blocks in .htaccess since this can make the file quite heavy and it is read on every visit by the web server.
     
    elicitservers, Sep 25, 2011 IP
  4. indyonline

    indyonline Prominent Member

    Messages:
    4,626
    Likes Received:
    248
    Best Answers:
    2
    Trophy Points:
    335
    #4
    Awesome! Thank you!
     
    indyonline, Sep 25, 2011 IP
  5. vpslist

    vpslist Peon

    Messages:
    88
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Better idea:

    Install Cloudflare as your DNS manager and use this feature with Cloudflare. It significantly cuts down on spambots and malicious things, including DDoS.
     
    vpslist, Oct 11, 2011 IP
  6. indyonline

    indyonline Prominent Member

    Messages:
    4,626
    Likes Received:
    248
    Best Answers:
    2
    Trophy Points:
    335
    #6
    I'll check into that. Thanks man
     
    indyonline, Oct 12, 2011 IP