Calculate IP subnet

  • Thread starter Thread starter MS Newsgroups
  • Start date Start date
M

MS Newsgroups

Hi,

does anyone have a function, or some insight in how i would go about to be
able to calculate the first and last address in a IP subnet based on a
network address and bits

Example 192.168.1.0 / 24

Should return

Firstaddresss 192.168.1.1
Lastaddress 192.168.1.254

OR -

192.168.1.32 / 27

FirstAddress 192.168.1.33
LastAddress 192.168.1.63

I know that there are IP subnet calculators out there, but i have not seen
any samples with source code.

All help would be much appreciated

Many thanks

Nick
 
let google be your guide...

2^(n-2)

hth,

steve


| Hi,
|
| does anyone have a function, or some insight in how i would go about to be
| able to calculate the first and last address in a IP subnet based on a
| network address and bits
|
| Example 192.168.1.0 / 24
|
| Should return
|
| Firstaddresss 192.168.1.1
| Lastaddress 192.168.1.254
|
| OR -
|
| 192.168.1.32 / 27
|
| FirstAddress 192.168.1.33
| LastAddress 192.168.1.63
|
| I know that there are IP subnet calculators out there, but i have not seen
| any samples with source code.
|
| All help would be much appreciated
|
| Many thanks
|
| Nick
|
|
 
Back
Top