How to block traffic from selected country

Intuz

New member
Joined
Nov 24, 2016
Messages
44
Points
0
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
 

onliveserver

New member
Joined
Jun 22, 2017
Messages
29
Points
0
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.
 

WeWatchYourWebsite

New member
Joined
Oct 10, 2017
Messages
3
Points
0
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.
 

genesis

New member
Joined
Oct 12, 2017
Messages
28
Points
0
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
 

dejan.kolar

New member
Joined
Aug 30, 2018
Messages
3
Points
0
You may try the CSF which has ability to filter out access by country codes.
 

BenSupportSages

New member
Joined
Jun 13, 2019
Messages
16
Points
0
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,BF,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,DE,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,MW,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,RU,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,UM,UY,UZ,VU,VE,VN,VG,VI,WF,EH,YE,ZM,ZW
 

alitce

New member
Joined
Feb 23, 2019
Messages
25
Points
0
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
 
Older threads
Replies
23
Views
4,394
Replies
4
Views
1,793
Replies
4
Views
1,550
Replies
9
Views
1,910
Replies
12
Views
2,801
Newer threads
Replies
15
Views
3,379
Replies
13
Views
6,019
Replies
18
Views
5,088
Replies
6
Views
2,269
Latest threads
  • Awaiting approval
FREE Respondent
Replies
0
Views
1
  • Awaiting approval
Hi
Replies
0
Views
1
  • Awaiting approval
Hi
Replies
0
Views
1
Replies
0
Views
1
  • Deleted
  • Deleted by Rob Whisonant
  • Reason: Looks like a new spammer getting ready to start
Replies
0
Views
1
Recommended threads

Latest postsNew threads

Referral contests

Referral link for :

Sponsors

Latest Blog ArticlesMost Viewed Threads

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top