Webmaster Sun Login
Not a member yet? Sign up

How to block traffic from selected country

  • HOME
  • FORUMS
  • WHAT'S NEW
  • BLOGS
  • MARKETPLACE
  • ADVERTISING
  • SPECIAL OFFERS
  • WEB HOSTING
  • QUICK MENU
  • REGISTER HERE - Join us for FREE
Results 1 to 11 of 11
    Stick this thread
  1. #1
    Join Date
    Dec 2016
    Posts
    34
    Thumbs Up/Down
    Received: 4/0
    Given: 1/0
    Thanks
    0
    Thanked 1 Time in 1 Post

    How to block traffic from selected country

    Hi everyone
    How to block traffic from selected country?

  2. #2
    Join Date
    Jun 2013
    Posts
    636
    Thumbs Up/Down
    Received: 97/1
    Given: 380/0
    Thanks
    254
    Thanked 131 Times in 103 Posts
    You can block traffic from selected country by block IP addresses (or IP ranges) from that country.

    Read more on this guide

    http://forumweb.hosting/13837-how-to-block-visitors-from-specific-countries.html

    Hope that helps!

  3. #3
    Join Date
    Dec 2016
    Posts
    34
    Thumbs Up/Down
    Received: 4/0
    Given: 1/0
    Thanks
    0
    Thanked 1 Time in 1 Post
    I think, this is very helpful, especially

    ip2location.com/blockvisitorsbycountry.aspx

    Thank you Alex

  4. #4
    Join Date
    Nov 2016
    Location
    CA
    Posts
    44
    Thumbs Up/Down
    Received: 11/0
    Given: 2/0
    Thanks
    0
    Thanked 4 Times in 3 Posts
    To block traffic from specific country, you can apply filter on geopgraphy.

    For example you want to block russian traffic from Google analytics, follow the below stepes:


    Filter Type: Custom filter > Include

    Filter Field: Country

    Filter Pattern: Russia

  5. #5
    Join Date
    Jun 2017
    Location
    India
    Posts
    29
    Thumbs Up/Down
    Received: 3/0
    Given: 0/0
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,

    First of install the csf on the serer after that Click on the Firewall Configuration button to open the configuration file and page, scroll down to the Country Code Lists and Settings section.

    ## Use the CC_DENY field to block by country code:
    The CC_DENY field accepts two-letter country codes.
    such as “US” for the United States of America, “GB” for Great Britain, and “DE” for Germany.
    IN this way the specific country code traffic has deny to server.

  6. #6
    Join Date
    Oct 2016
    Location
    Milwaukee, WI
    Posts
    58
    Thumbs Up/Down
    Received: 3/0
    Given: 11/0
    Thanks
    4
    Thanked 2 Times in 2 Posts
    You can do this with Cloudflare or a .htaccess rule.

  7. #7
    Join Date
    Oct 2017
    Posts
    3
    Thumbs Up/Down
    Received: 0/0
    Given: 1/0
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I realize I'm late on this, but you'll want to block the IP addresses (or ranges) as far up the "chain" as possible.

    In other words, if you're blocking them with .htaccess or similar level, that means the traffic has already "hit" your site.

    If you block at the iptables level, then you're saving website processing (Apache, Nginx...) for your website.

    Let me know if you have further questions about this.

  8. #8
    Join Date
    Oct 2017
    Posts
    28
    Thumbs Up/Down
    Received: 0/0
    Given: 0/0
    Thanks
    0
    Thanked 1 Time in 1 Post
    This will actually depends on the internet provider you are using. VPN is now a trend. If you tend to use VPN and want to block countries for your site, I'd prefer not to do it. Because once you logged into another device, your settings will be refreshed. Better have a suitable internet provider first. Then follow the steps the others have given. Ciao

  9. #9
    Join Date
    Aug 2018
    Posts
    3
    Thumbs Up/Down
    Received: 0/0
    Given: 0/0
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You may try the CSF which has ability to filter out access by country codes.

  10. #10
    Join Date
    Jun 2019
    Posts
    16
    Thumbs Up/Down
    Received: 0/0
    Given: 0/0
    Thanks
    0
    Thanked 0 Times in 0 Posts
    1. Adding rules in htaccess

    You can use the link: https://www.ip2location.com/free/visitor-blocker to generate the range of IP's which needs to be blocked

    2. Using Cloudflare CDN

    You can find the instructions to so here: https://support.cloudflare.com/hc/en-us/articles/217074967-Configuring-IP-Access-Rules

    3. Using CSF

    In the csf configuration file (/etc/csf/csf.conf), there is an option to block/allow access from an IP range by using country code. Here I’m going to explain how to allow or deny IP range using this feature.

    For allowing a country to your server you can use the directive ‘CC_ALLOW‘ from the csf configuration file

    CC_ALLOW = ""

    Similarly, you can deny by using the directive ‘CC_DENY‘

    CC_DENY = ""

    Each option is a comma separated list of CC’s, e.g. “US,GB,DE”

    You need to restart the csf service to get the changes to be worked. Run the following command for restarting the csf service.

    csf -r

    Country codes:
    AF,AL,DZ,AS,AD,AO,AI,AQ,AG,AR,AM,AW,AU,AT,AZ,BS,BH ,BD,BB,BY,BE,BZ,BJ,BM,BT,BO,BA,BW,BV,BR,IO,BN,BG,B F,BI,KH,CM,CA,CV,KY,CF,TD,CL,CN,CX,CC,CO,KM,
    CG,CD,CK,CR,CI,HR,CU,CY,CZ,DK,DJ,DM,DO,TP,EC,EG,SV ,GQ,ER,EE,ET,FK,FO,FJ,FI,FR,FX,GF,PF,TF,GA,GM,GE,D E,GH,GI,GR,GL,GD,GP,GU,GT,GN,GW,GY,HT,HM,VA,
    HN,HK,HU,IS,IN,ID,IR,IQ,IE,IL,IT,JM,JP,JO,KZ,KE,KI ,KP,KR,KW,KG,LA,LV,LB,LS,LR,LY,LI,LT,LU,MO,MK,MG,M W,MY,MV,ML,MT,MH,MQ,MR,MU,YT,MX,FM,MD,MC,MN,
    MS,MA,MZ,MM,NA,NR,NP,NL,AN,NC,NZ,NI,NE,NG,NU,NF,MP ,NO,OM,PK,PW,PA,PG,PY,PE,PH,PN,PL,PT,PR,QA,RE,RO,R U,RW,KN,LC,VC,WS,SM,ST,SA,SN,SC,SL,SG,SK,SI,
    SB,SO,ZA,GS,ES,LK,SH,PM,SD,SR,SJ,SZ,SE,CH,SY,TW,TJ ,TZ,TH,TG,TK,TO,TT,TN,TR,TM,TC,TV,UG,UA,AE,GB,US,U M,UY,UZ,VU,VE,VN,VG,VI,WF,EH,YE,ZM,ZW

  11. #11
    Join Date
    Feb 2019
    Posts
    20
    Thumbs Up/Down
    Received: 1/0
    Given: 0/0
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by YacaZG View Post
    Hi everyone
    How to block traffic from selected country?
    Hello YacaZG
    If your site is wordpress you can block countries from their IP address, but if your site is not wordpress, you can block it via the server directly

Newer Threads

  1. John Ryan
    Make Money on jvzoo
    By John Ryan in forum Make Money Online
    daniel27lt
    Replies: 15 | Views: 2922
    Last post by daniel27lt, 07-17-2017, 01:54 PM
  2. YacaZG
    Sirarpi3
    Replies: 13 | Views: 4871
    Last post by Sirarpi3, 05-24-2018, 02:02 PM
  3. Webynk
    CookieRunner
    Replies: 18 | Views: 3725
    Last post by CookieRunner, 10-24-2017, 11:21 AM
  4. YacaZG
    YacaZG
    Replies: 6 | Views: 1711
    Last post by YacaZG, 12-06-2016, 06:35 AM
  5. EpicGlobalWeb
    Ron Killian
    Replies: 3 | Views: 1512
    Last post by Ron Killian, 01-28-2017, 04:34 AM

Older Threads

  1. John Ryan
    SEO my site
    By John Ryan in forum Search Engine Optimization
    paritosh
    Replies: 23 | Views: 3844
    Last post by paritosh, 11-15-2018, 03:58 PM
  2. YacaZG
    Audience Network
    By YacaZG in forum Facebook
    YacaZG
    Replies: 4 | Views: 1510
    Last post by YacaZG, 12-09-2016, 06:40 AM
  3. YacaZG
    YacaZG
    Replies: 4 | Views: 1275
    Last post by YacaZG, 12-03-2016, 06:21 PM
  4. YacaZG
    ngoctam699
    Replies: 9 | Views: 1549
    Last post by ngoctam699, 12-04-2016, 03:16 AM

Latest Threads

  1. jowel
    jowel
    Replies: 0 | Views: 30
    Last post by jowel, Yesterday, 01:09 PM
  2. HostXNow
    HostXNow
    Replies: 0 | Views: 155
    Last post by HostXNow, 10-10-2019, 02:16 PM
  3. HostXNow
    HostXNow
    Replies: 0 | Views: 166
    Last post by HostXNow, 10-10-2019, 02:12 PM
  4. PaymentGateway
    PaymentGateway
    Replies: 3 | Views: 175
    Last post by PaymentGateway, 10-14-2019, 05:12 AM
  5. arindamb
    ORLOVA
    Replies: 2 | Views: 275
    Last post by ORLOVA, Yesterday, 07:02 AM

Similar Threads

  1. Harry P
    Do you block spiders?
    By Harry P in forum Web Hosting
    cre8ivemedia
    Replies: 5 | Views: 1803
    Last post by cre8ivemedia, 03-14-2017, 02:54 PM
  2. Tshepo
    hostslim
    Replies: 2 | Views: 1412
    Last post by hostslim, 11-19-2015, 11:02 AM
  3. JoanHumphreys
    TheLifeStyleMentor
    Replies: 1 | Views: 1762
    Last post by TheLifeStyleMentor, 06-18-2015, 11:48 AM
  4. success druggy
    aliblogger
    Replies: 10 | Views: 3202
    Last post by aliblogger, 12-24-2014, 06:58 PM
  5. vaneetagoswami
    Dopani
    Replies: 1 | Views: 1808
    Last post by Dopani, 12-12-2014, 03:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Internet Marketing Forum

Webmaster Sun is a forum where you’ll find in-depth discussions and resources to help you succeed on the web whether you are new or experienced. You’ll find it all here. With topics ranging from internet marketing, search engine optimization, social networking, make money online, web hosting, affiliate marketing as well as hands-on technical support for web design, programming and more. We are a growing community of like-minded people that is keen to help and support each other with ambitions and online endeavors. Learn and grow, make friends and contacts for life.

Come Hang Out With Us

    Facebook Twitter Webmaster Forum Google+

    Webmaster Sun Logo
Copyright ©2012 - 2019, WebmasterSun.com. All rights reserved. Internet marketing forum for internet marketers, webmasters, web hosting providers, designers and affiliate marketers.

Welcome to Webmaster Sun

The World's Number 1 Webmaster Community, SEO and Marketplace

Log in!

Continue with Facebook
Continue With Email. By signing up you indicate that you have read and agree to the Terms of Service and Privacy Policy.

Sign in Manually

Need an account? Sign up now!