Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!

ankur rathi
Ranch Hand
Posts: 3830
This post is related to subnet (sub network). Please move it if it's not in right place.

Theoretically, a subnet is a logical group of hosts (systems) in a bigger network. They have an IP address in following format xx.xx.xx.xx/xx

Now if someone gives me a subnet address (195.23.24.29/24). Can I get IP addresses of all the hosts in this subnet?

Here is my understanding:

Any IP address has two parts (first 3 octets represent network (xx.xx.xx) & 4th octet is host).
Coming back to subnet & my example, the 24 after the slash (/) represent the subnet mask (?). It means 24 ones & remaining (32-24 = 8) zeros.

11111111 11111111 11111111 00000000
255.255.255.0

Also the first (00000000) & last (11111111) can’t be used for hosts as first is for network & last is for broadcast. So we’ll have combinations starting from 00000001 till 11111110. Total 254 combinations or hosts in this subnet.

They’ll have IPs: 195.23.24.1, 195.23.24.2, 195.23.24.3 ………………………….. 195.23.24.254.

Is my understanding about subnet & above calculation correct?

I’ll provide another example to clarify my understanding:
11111111 11111111 11111111 11100000
00000 & 11111 can’t be used. Combinations left are: 00001 till 11110.
Host IPs are: 195.23.24.1, 195.23.24.2, 195.23.24.3 …………………………… 195.23.24.30
Total 30 hosts are in the subnet.

If it’s correct then the 4th octet in subnet address is useless, we’re not using it for any purpose??

Thanks.

Henry Wong
author
Marshal
Posts: 21112
78
ankur rathi wrote:I’ll provide another example to clarify my understanding:
11111111 11111111 11111111 11100000
00000 & 11111 can’t be used. Combinations left are: 00001 till 11110.
Host IPs are: 195.23.24.1, 195.23.24.2, 195.23.24.3 …………………………… 195.23.24.30
Total 30 hosts are in the subnet.

Actually the Host IPs are: 195.23.24.65, 195.23.24.66, 195.23.24.67 …………………………… 195.23.24.94

Henry

ankur rathi
Ranch Hand
Posts: 3830
Henry Wong wrote:
ankur rathi wrote:I’ll provide another example to clarify my understanding:
11111111 11111111 11111111 11100000
00000 & 11111 can’t be used. Combinations left are: 00001 till 11110.
Host IPs are: 195.23.24.1, 195.23.24.2, 195.23.24.3 …………………………… 195.23.24.30
Total 30 hosts are in the subnet.

Actually the Host IPs are: 195.23.24.65, 195.23.24.66, 195.23.24.67 …………………………… 195.23.24.94

Henry

Thanks Henry.

195.23.24.76/27
195.23.24.01001100
27 -> 11100000

consider only bits where subnet mask is having 1s, ignore rest.
195.23.24.010-00000

since 00000 & 11111 can't be used.

195.23.24.01000001 will be first host (195.23.24.65). 195.23.24.66 ................. 195.23.24.01011110 (195.23.24.94) will be last.

Thanks again Henry!
:)