Forum Moderators: phranque

Message Too Old, No Replies

help on how to block range of IP address

         

rheno robert

1:14 pm on Mar 6, 2011 (gmt 0)

10+ Year Member



Hi! I'm a new web owner and I target just specific countries, my country untargeted so i want to block it and will allow only my ip.

how can i do this?

I am using the ip block in .htaccess

this is my ip 112.210.250.38

I noticed than when i removed this ip range (deny from) "112.208.0.0/14" i can access my website. but other ip's on that range can also access it i guess..

how to do it? please help. Thank you very very much

rheno robert

1:18 pm on Mar 6, 2011 (gmt 0)

10+ Year Member



I forgot to add that I've put my ip on allowed ip prior to first line of "deny from" - it did not work but when i removed the ip range 112.208.0.0/14 only then i can access my website.

wyweb

1:33 pm on Mar 6, 2011 (gmt 0)



You can get a country specific IP range. A list I mean.

Geotarget? Is that the site?

It's Sunday morning and I'm brain dead.

Google's your friend though, you know. Or can be anyway.

If nobody's answered in the next few hours I'll get back.

There are lists you can download at no charge.

wyweb

1:54 pm on Mar 6, 2011 (gmt 0)



mysimpleads can give you a complete list. I don't know if it's still free or not. Check it out.

mysimpleads is a good ad management system. It used to be free, maybe still is. I was going with YPN in favor of adsense but YPN was saying we couldn't show ads outside the US. I needed a way to show YPN ads to only US visitors and then serve adsense to everyone else. mysimpleads was a perfect solution and it was free, which goes over big with me.

rheno robert

2:16 pm on Mar 6, 2011 (gmt 0)

10+ Year Member



Hello! thank you for the fast reply. I found a great site here.

yap i tried google but i can't really understand it.

I just want to exclude my ip 112.210.250.38 from being blocked in this IP range 112.208.0.0/14

thanks again

wyweb

2:38 pm on Mar 6, 2011 (gmt 0)



i tried google but i can't really understand it.

Well, no one really does.

wyweb

2:43 pm on Mar 6, 2011 (gmt 0)



Let me go a little further here.

You can deny an entire range

In your .htaccess file it would look like this:



<limit GET>
order allow,Deny
Deny from 122.160
allow from all
</Limit>



That allows from everyone else except those caught in that.

rheno robert

2:46 pm on Mar 6, 2011 (gmt 0)

10+ Year Member



i mean i;ve done a search, there has answers but i can't the answers since they are i guess for advance coders. thanks

rheno robert

2:52 pm on Mar 6, 2011 (gmt 0)

10+ Year Member



yap but what i want is just to exclude

112.210.250.38

so that it will not be blocked here 112.208.0.0/14

i can't understand /14. i know that by blocking 112.208.0.0 will block same as 112.208

thanks again

wilderness

3:41 pm on Mar 6, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Such exclusions may not be accomplished in mod_access, rather you'll need to use mod_rewrite.

I would also suggest you provide more depth in range to your own IP range, unless your provided with a FIXED IP?

Please note; other lines and/or required data is necessary in order for the following RewriteCond to function.
Please refer to Forum Library [webmasterworld.com]

RewriteCond %{REMOTE_ADDR} ^112.(20[89]|211)\. [OR]
RewriteCond %{REMOTE_ADDR} ^112.210\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[1-5])\. [OR]
RewriteCond %{REMOTE_ADDR} ^112\.210\.250\.([0-9]|[12][0-9]|3[0-79]|[4-9][0-9]|1[0-9][0-9]|2[0-5][0-9])$

rheno robert

4:18 pm on Mar 6, 2011 (gmt 0)

10+ Year Member



hi! thanks.

i have found a solution perhaps but i can't really understand it so much.

here.

[help.yahoo.com...]

i hope i can do CIDR or netrange

regards

wilderness

4:33 pm on Mar 6, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The following explanation (on the URL you've provided) is more applicable to what your attempting to accomplish:

Removing an IP Address from the Block List

rheno robert

4:52 pm on Mar 6, 2011 (gmt 0)

10+ Year Member



really then how can i exclude it? i can't understand that /14 in the end.

so if i exclude 112.210.250.38 from this 112.208.0.0/14

how could i do it?

can i do it this way?

112.208.0.0 - 112.210.0.37?

but i don't really understand.

what range does this code block? (112.208.0.0/14)

thank you

wilderness

5:00 pm on Mar 6, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



really then how can i exclude it? i can't understand that /14 in the end.


You really cannot use the method provided in your URL unless, you are a Yahoo Merchant whom utilizes their Merchant Tools.
The explanations provided therein are only intended to be utilized with their server and not in "general htaccess solutions".

what range does this code block? (112.208.0.0/14)


112.208.0.0 - 112.211.255.255

In summary, the Rewrite COND lines I previously provided are the most effective solution.

rheno robert

5:07 pm on Mar 6, 2011 (gmt 0)

10+ Year Member



thank you very very much for your explanation. I will try then that rewrite tom. its past 12 midnight here. gotta sleep :-)

but laat can you explain to me that /14?

I noticed 208 - 211 change

thank you very much for your time

wilderness

5:13 pm on Mar 6, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



but laat can you explain to me that /14?


CIDR Wiki [replay.waybackmachine.org]

more CIDR [replay.waybackmachine.org]

rheno robert

5:15 pm on Mar 6, 2011 (gmt 0)

10+ Year Member



thank you so much. will research more tomorrow. regards and nice day

wyweb

6:19 pm on Mar 6, 2011 (gmt 0)



i have found a solution perhaps but i can't really understand it so much.

Well, don't give up. You'll get help here.

Sometimes it's hard to understand the question though. If we keep pecking at it we'll get to it though.

wilderness

3:08 pm on Mar 7, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



FWIW,
There are two syntax errors in the previous lines that I provided.

They both are the same, as I failed to escape the period trailing the 112 Class A.

Both should begin with:
RewriteCond %{REMOTE_ADDR} ^112\.

rheno robert

2:03 am on Mar 8, 2011 (gmt 0)

10+ Year Member



Hello Thank you. I am learning. :-)

I have another question.

what range does this code block? (112.208.0.0/14)

your anwswer: 112.208.0.0 - 112.211.255.255

How did you get that range. I found some anwswer on this guide

[ehow.com...]

but the author did not explain further how he converted that 4 octets into an IP.

can you explain this more?

Regards

wilderness

2:40 am on Mar 8, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



what range does this code block? (112.208.0.0/14)


I used an online CIDR Calculator (these tools will test any persons patience)

This range is a CIDR and is explained in both the link you provided (this is really a bad and incomplete explanation) today and the two links I provided yesterday.

but the author did not explain further how he converted that 4 octets into an IP.


I don't see where the author converted anything to anything useable.

When you do a search for an IP at either one of the online Registars and their WHOIS options, you are provided with both IP ranges and CIDR ranges (at least in most instances).
Additionally there are many only tools that allow WHOIS searches.

Some where, I've a link to a previous thread at Webmaster World which explains converting an IP range to Regex, there may even be one in the forum library.
The conversion to Regex is a learned process and many find it too time consuming and high-risk for syntax errors.

Most folks prefer using mod_access, however as I mentioned previously, mod_access is not as compact as mod_rewrite in complex ranges, and especially those with non-sequential ranges (such as your 250.38).

rheno robert

12:20 pm on Mar 8, 2011 (gmt 0)

10+ Year Member



for others looking for an answer.........

The answer to my questions is very very easy which we overlook. In my cpanel I just entered the range and pop there's the code generated in my htaccess. I've been seeing that Ip deny manager when i entered cpanel but i never used it, but thank you very very much for your time wilderness.

Regards

wilderness

1:06 pm on Mar 8, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



for others looking for an answer.........


Glad you found a solution.

FWIW, and for the record, most cpanel's create badly coded syntax in regex. It will surely return to bite you in the backside.

Google offers a "Regex IP Generator - Analytics Help" tool, which I did not provide a link to for the same reason.

rheno robert

6:12 am on Mar 9, 2011 (gmt 0)

10+ Year Member



one way to make sure i am not blocking targeted visitors is by monitoring who was block/redirected to my secondary site.

the IP's that were blocked are automatically redirected to my secondary site.

I can see that i did not blocked any targeted visitors so untill its good I'll use that ip deny manager in cpanel.

Regards