|
 |
asp_web_howto thread: IP Subnet Calculation
Message #1 by "Marcelo" <cyborg@m...> on Thu, 15 Feb 2001 16:34:34 -0300
|
|
Does anybody has a routine to take client IP and check against a database
which has the IP range and the IP mask (example below) and determine if
that IP es inside that range?
Example: I get this IP from the client machine: 192.168.22.135
in the database, I've 192.168.22.0 and mask 255.255.255.0 obviously, this
IP is inside, because the mask is zero...but if it was 248?
<Marcelo/>
<email>cyborg@m...</email>
Message #2 by "Ken Schaefer" <ken@a...> on Fri, 16 Feb 2001 12:23:25 +1100
|
|
Pick up a book on TCP/IP which includes some description on subnetting:
248 in a mask is:
11111000
The ones in the mask indicate which part of the octet is used for the
NetworkID, ie the first five digits. Everything else is part of the nodeID.
In your DB, you'd have to have several entries for 192.168.22.xxx because
the NetworkID is also part of the 4th octet. You'd have to work out which of
those networks the machine was in.
For example the first network would be:
00000-001 through 00000-110 (ie 192.168.22.1 -> 192.168.22.6)
the second network would be:
00001-001 through 00001-110 (ie 192.168.22.9 -> 192.168.22.14)
And this is all assuming they're not using CIDR...
Cheers
Ken
----- Original Message -----
From: "Marcelo" <cyborg@m...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Friday, February 16, 2001 6:34 AM
Subject: [asp_web_howto] IP Subnet Calculation
> Does anybody has a routine to take client IP and check against a database
> which has the IP range and the IP mask (example below) and determine if
> that IP es inside that range?
>
> Example: I get this IP from the client machine: 192.168.22.135
>
> in the database, I've 192.168.22.0 and mask 255.255.255.0 obviously, this
> IP is inside, because the mask is zero...but if it was 248?
>
> <Marcelo/>
> <email>cyborg@m...</email>
|
|
 |