Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to allow an IP range in .htaccess [closed]

Tags:

.htaccess

I want to allow all IP Addresses between 145.050.039.008 and 145.050.039.017 inclusive

For example (but this doesn't work):

allow from 145.050.039.008 145.050.039.017

or:

allow from 145.050.039.008,145.050.039.017

or:

allow from 145.050.039.008/017

?

Thanks, Jelmar

like image 971
Jelmar Avatar asked Jun 06 '12 09:06

Jelmar


People also ask

How do I allow an IP address range?

Click IP Address Manager > IP Addresses > Manage Subnets & IP Addresses. In the network tree pane on the left, click the subnet to which you want to add your new IP address range. Click Add IP Range. Enter the starting IP address and the ending IP address of your IP address range.

How do I whitelist an entire IP range?

To whitelist, an IP or IP range provides the CIDR notation by open the 'Whitelisted IPs' tab and tap on the "Add IP" button then input the data. This will whitelist the entire IP addresses under that subnet or the IP CIDR and Port.

How do I restrict IP address in htaccess?

htaccess or you want to create settings for a list of addresses, all you need to do is: Create . htaccess file in your public_html folder. Add lines based on your preferences.

How do I deny access to my site with an .htaccess file?

htaccess IP deny access. To deny access to a block of IP addresses, simply omit the last octet from the IP address: deny from 123.456. 789.


1 Answers

A̶l̶l̶o̶w̶ ̶f̶r̶o̶m̶ ̶1̶4̶5̶.̶0̶5̶0̶.̶0̶3̶9̶.̶0̶0̶8̶ ̶1̶4̶5̶.̶0̶5̶0̶.̶0̶3̶9̶.̶0̶1̶7̶

C̶h̶e̶c̶k̶ ̶h̶e̶r̶e̶ ̶f̶o̶r̶ ̶d̶e̶t̶a̶i̶l̶s̶.̶


(late) EDIT:

My bad, my previous answer never worked, at this time I answered without really understanding the problem.

Option #1: define all IP

Here's the only way to do it:

Allow from 145.50.39.8
Allow from 145.50.39.9
Allow from 145.50.39.10
Allow from 145.50.39.11
Allow from 145.50.39.12
Allow from 145.50.39.13
Allow from 145.50.39.14
Allow from 145.50.39.15
Allow from 145.50.39.16
Allow from 145.50.39.17

Option #2: use a partial IP

If you want something more generic, you can use a partial IP:

Allow from 145.50.39

But this will allow IP from 145.50.39.0 to 145.50.39.255.

Option #3: use a netmask or a CIDR

To get even closer, you can use a netmask or a CIDR:

Allow from 145.50.39.0/255.255.255.224

or

Allow from 145.50.39.0/27

This will allow IP from 145.50.39.0 to 145.50.39.31.

like image 129
zessx Avatar answered Jan 01 '23 23:01

zessx