Answer the question
In order to leave comments, you need to log in
How to make access to the site only with ip from Russia?
How to make access to the site only with ip from Russia?
Answer the question
In order to leave comments, you need to log in
to the .htaccess file the following code:
< LimitExcept > <--- Remove spaces<--- Remove spaces
Order deny,allow
deny from all #List
of IPs from which access is allowed
Allow from
< /LimitExcept >
< LimitExcept > <--- Remove spaces<--- Remove spaces
Order deny,allow
Allow from all #List
of IPs from which access is denied
Deny from
< /LimitExcept >
In my opinion, one should immediately assume that the mapping of IPv4 prefixes to geographic characteristics (countries) is not the most straightforward thing. I think that in the future there will be more and more resale (rent) of prefixes, leading to a change in this display, this should be taken into account.
Technically, I see the following possibilities:
1) ACL on network equipment. You make a list of "Russian" prefixes, translate them into ACLs, attach them to the required interface. Pros: line-rate (or close to line-rate) performance. Cons: not every equipment is suitable (TCAM size, etc.), possible exceptions (the client complains that he is from Russia, but the site does not open) will have to be registered in the ACL every time (maybe not very convenient). It should be used if the volume of unwanted traffic is large (flooding, etc.) and this traffic really affects the performance of your server.
2) filtering on the web server itself (geoIP module). Pros: more flexibility. Cons: performance is limited by the performance of the geoIP database.
3) a combination of paragraphs. 1) and 2). Coarse filtering using ACLs, more flexible - on the web server itself.
4) the simplest is to hide behind a CDN frontend that provides such a service.
There are, of course, more specific options, but I think these are enough for you (or rather, the second or fourth).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question