top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Apache: Converting ip regex to iprange

+1 vote
385 views

I have about 500 + ip regex in my apache file like this

99.45.3[2-9]..*$ 
^99.45.4[0-9]..*$ 
^99.45.5[0-9]..*$ 

I have to convert like this into CIDR .

99.45.32.0/21
99.45.40.0/21
99.45.48.0/23
99.45.50.0/21
99.45.58.0/23

Is there a module that can help me convert ip regex to ip range .

posted May 28, 2014 by Amit Mishra

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+1 vote

I tried both of the following methods to block an ip address, but neither worked. In .htaccess, I put:

Order Deny,Allow
Deny from 123.123.123.123

and 

RewriteCond %{REMOTE_ADDR} ^123.123.123.123
RewriteRule .* /maintenance.html [R=503,L]

(I do have the mod_rewrite module installed). In both cases, I put the rules at the top of the file so that it would be the first rules executed.

After each one, i did an apachectl stop, then apachectl start. In both cases, when i monitored my site with the server-status module, the ip address was still there, with sometimes more than 30 requests, and all for the same page, which was ..../login.php. And it continued to be there for the next 30 minutes until it just dropped off, but i was doing nothing to stop it at that point.

This method of blocking has worked for me in the past.

Is it possible for someone to bypass my blocking method(s)? Or is there something more I need to do?

+2 votes

I'm trying to use the new If directive present from Apache 2.4, to configure an htaccess based authentication for a specific Location based to the client IP address. If a client hasn't an IP address related to the internal VLAN, I would set the password access.

What is the correct syntax to have this configuration? I noticed on the documentation that there is the "-ipmatch" condition, but I don't understand well this feature.

0 votes

I am new to apache, so forgive me if this is a beginner questions.

I am trying to redirect request to apache based on the IP address. Depending on where the request originates from, the request will either have a external or internal IP address. External will be redirected to the external site, internal will be redirected to the internal site.

Request to www.site.com will be evaluated based on the IP address. Then redirected to either www.site.com/external or www.site.com/internal . I am able to accomplish this with the following.

 RewriteCond %{REMOTE_ADDR} ^1.1.1.1 
 RewriteRule ^(.*)$ www.site.com/internal [R=301,L] 
 RewriteCond %{REMOTE_ADDR} ^2.2.2.2 
 RewriteRule ^(.*)$ www.site.com/external [R=301,L] 

The problem I am running into is that this is in a loop. Every request will be evaluated and redirected. If possible, I need a way to redirect once, then let other request (www.site.com/external/a/b/c or www.site.com/internal/x/y/z )not be evaluated and then redirected

...