Block Range of IPs - .htaccess

I'm trying to block a range of IPs from visiting my website
Here is what I have in my .htaccess file
order allow,deny
Deny from 64.244.0.0/64.245.255.255
Deny from 64.244.0.0/15
allow from all
I'd like to know if anyone can tell (or estimate) me how many IPs have i blocked there?

I believe the first DENY FROM is just wrong. I've always seen it this way
64.244.0.0/15
Base Address^ ^Number of bits to use for subnet
This would mean that you have 2^15 addresses in the deny block.
Edit
Using the comments below, what you would want is
ORDER deny,allow
DENY from 64.244.0.0/15
ALLOW from all

Related

How to Block an IP range using .htaccess file

I want to block access of the following ips
https://gyazo.com/f41a53a1a385e41fe669064bff844a3a
i guess that comes in the range of
176.123..
so will this work ?
Order Allow,Deny
Deny from 176.123.0.0/16
Allow from all
also i have to keep this htaccess outside public_html folder ?
This should do the task
Order Allow,Deny
Deny from 176.123.0.0/16
Allow from all
and as Eric said the people within this ip rage can still access your site via a proxy server.
But if the allowed users have a particular ip range then this can sort it out
Order Allow,Deny
Deny from all
Allow from *ip range*

htaccess allow from 192.168.1.* isnt working

I made the following .htaccess Code, which typically should give access to the folder from internal network but external havent access.
The Problem: with 192.168.1.* I get blocked, with 192.168.1.49 (my local IP) I have access.
Does anybody have a clue why the IP range is blocked, but specific IP is allowed and how to get this fixxed?
Thanks and Cheers
AuthUserFile /home/.htpasswd
AuthType Basic
Require valid-user
Order Deny,Allow
Deny from all
Allow from 192.168.1.*
Satisfy any
Block access to all visitors except yourself using entire network ip
order allow,deny
allow from 192.168.
deny from all
It is also possible to block users by their host name.
order allow,deny
allow from stackoverflow.com
deny from all
If you want to access with particular ip then use the following command,
order allow,deny
allow from 192.168.0.10
deny from all

.htaccess Restrict/Allow by IP address to specific page

What I'm looking for is something along the lines below but instead of restricting access to the whole domain I want to restrict only a specific page and allow certain IP's to access it. Is this possible? Everywhere I searched is only for restricting the whole site. Thank you.
ErrorDocument 403 http://www.domainname.com
Order deny,allow
Deny from all
Allow from 124.34.48.165
Allow from 102.54.68.123
You can use a code like this
<Location /example-map>
Order deny,allow
deny from all
allow from 123.12.12.12
allow from 123.123.43.43
</Location>
This by the 123... the ip from the allowed ip's and /example-map the location
by RedDev

.htaccess: how to deny access to all except by me for specific folder

i want an exclusive access in my administration folder and i tried this code (in an .htaccess file inside admin folder):
order allow,deny
allow from m.y.i.p
deny from all
tried also this:
order deny,allow
deny from all
allow from m.y.i.p
and this:
order deny,allow
allow from m.y.i.p
deny from all
but anytime server gives me this response:
403 Forbidden
Forbidden
You don't have permission to access /provo/prova/ on this server.
how can i solve this issue? i have a switch connected to the router/modem and i take my ip address from this site http://whatismyipaddress.com/
thanks.
This worked for me:
Order deny,allow
deny from all
allow from m.y.i.p
However, since you've already tried it, you need to make sure that's the IP the webserver is seeing. Look at the access logs right after you load a page to see what IP got logged.
Other than that, make sure that you've put these in the right place. Either the htaccess file in the directory you want to protect, or in a <Directory> block in your server/vhost config.
Prob not the answer you're looking for but:
If you're using cPanel .. it's really easy to do it from there.
It involves making a passwords file. I never remember the exact way cause I always get cPanel to do it for me.
I would only do it by IP if you have been given a static IP from your ISP... otherwise this could change.
Use .htpasswd. It's a bit more resilient than just using an IP address.

How to allow access only within country

I found this web site to generate a .htaccess to block an access from certain country.
The problem with this is that I want to allow access only within Norway. If I use this service, the list will be very long since I have to list all the country IP addresses.
Is there any way to allow access within country, my case is Norway?
Change all occurences of 'deny' to allow, and all occurrences of 'allow' to deny. Then move the 'deny from all' condition at the end to the beginning of the list.
eg.
<Limit GET HEAD POST>
order allow,deny
deny from 41.205.32.0/19
deny from ....
allow from all
</LIMIT>
becomes
<Limit GET HEAD POST>
order deny,allow
deny from all
allow from 41.205.32.0/19
allow from ....
</LIMIT>
There's some good tutorials about .htaccess.
There are many geoip database vendors that offer solutions for the problem detailed instructions on the subject. Check out http://www.maxmind.com/app/mod_geoip for an apache module that comes with their database which would probably be a perfect fit for your problem.

Resources