You are here: Re: Matching IP scopes. « PHP Programming Language « IT news, forums, messages
Re: Matching IP scopes.

Posted by Oli Filth on 02/27/06 22:05

Sandman said the following on 27/02/2006 19:59:
> So, I have this list of valid IP scopes, in the form below. How do I
> match if $_SERVER[REMOTE_ADDR] is covered in any of these scopes?
>
> 193.11.120.0/21
> 193.11.128.0/24
> 193.11.129.0/24
> 193.11.130.0/24
> 193.11.131.0/24
>
>
> First, I don't really know how to interprete the "/24" ending. I am
> guessing that "193.11.131.0/24" means "193.11.131.X to 193.11.131.Y"
> or something, but what? When that's translated to something useful,
> how do I match IP numbers reliably?

The /XX represents the length of the subnet mask in bits, so your hunch
is pretty much correct.

An IP address matches a given network IP address if:

(Address ^ Mask) == (NetAddress ^ Mask)

where Mask = 11111...0000, the number of ones given by the /XX.


--
Oli

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация