1. ## why can't ip address contain 256 in it ?

i have the basic knowledge as ip adress means it is a made of 4 octets.

But i have some basic doubts like below

1) why does it cannot have like 192.168.17.256 in it ..?

2) I have an example here

If i have a small organization and i want to get some public ips for all my systems from my nearest ISP

does he give a specific subnet ..? from here i need to calculate and give ips OR

or he gives a list of ips to use ..?

what is the general procedure ?

iam trying to understand the ip addressing and subnet concepts thorougly , if any body can
give some good tutorial urls it would be great help for me.

2. Because each of the elements (a.b.c.d where a, b, c and d are elements) is 8 bits, and 256 takes 9 bits to store this value (in 8 bits, 256 is the same as zero, it's like in old cars, when the car has done 100000 miles/kilometers, it says "00000" on the odometer).

And it's your subnet mask that says how many of the bits in your address are "fixed by the service provider". For example, if you have 255.255.255.192 in the subnet mask, you've got 6 bits that are "private" to your network.

--
Mats

3. ## 255.255.255.192 number of networks / hosts in it ?

In this case i left with 6 bits

lets think that they gave public ip as 152.167.70.24 and subnet mask as

255.255.255.192

so 000000 and 111111 cannot use as it would be used for broadcast address .

from here how can i go further like number of networks and the number of hosts calculation?

if iam not wrong the number of host would be like

000001

000010

000011

.
.
.
.
.
111110

please correct me if iam going wrong ..

thanks

4. Yes, you'd have 2^6 = 64 - 2 addresses in that subnet.

Of course, you can put a router in at any time and make your own private network, e.g. using 192.168.0.1 with 255.255.255.0 for subnet, which gives you another 254 usable addresses.

--
Mats

5. ## Ip range with the above subnet and IP?

If we consider our ip as 152.167.70.24 as our ip

then i feel the range of ip we can use is from 152.167.70.1 to 152.167.70.30

am i right ..?

do we have any formula so that i can just cross check that the number of host addresses i got is correct or not ?

6. 256-192 = 64, so you have 64 (-2) addresses that are available for your use with the .192 on the end of the subnetmask.

--
Mats

7. To expand on what matsp said, a .192 netmask would make the valid addresses for that range 152.167.70.0 (network) through 152.167.70.63 (broadcast), leaving 1 through 62 available for your use, but one of them must be a router, unless your service provider handles the routing.

8. Totally not a Linux thread. Moving to Tech.

9. Originally Posted by vlrk
The base and broadcast addresses are usually the first and last address of a subnetwork. If you need to calculate them for some reason, given some IP and its subnet mask:

- The network address, or network portion- is calculated by simply ANDing the mask with the IP: mask && ip

EDIT: mind you that there are no broadcast and network addresses for 1 bit network masks, or point-to-point networks. This is the only exception I'm aware to the above rule. Which means it's still possible to connect two computers in network with a 255.255.255.254 mask.

10. ## calculating the subnet mask ?

Of course, you can put a router in at any time and make your own private network, e.g. using 192.168.0.1 with 255.255.255.0 for subnet, which gives you another 254 usable addresses.
if we take the above case then

now ~mask | ip will be 192.168.0.255

total from 2 to 254 which are 254 usable addresses

Now my dobut is if i have ip like 192.168.68.0 and i need calculate the subnetmask in such a way that i can only give ony 10 usable ips any shortcuts
like above ..?

thanks

11. You can only partition networks in powers of 2, so 1, 2, 4, 8, 16 etc. If you want to give someone 10 addresses, you actually need to use a netmask of 255.255.255.240, which gives it 16 addresses. You can thus, split 192.168.0.0 network into 16 sections of 16 addresses, giving each group:
192.168.0.0 .. 192.168.0.15
192.168.0.16 .. 192.168.0.31
192.168.0.32 .. 192.168.0.47
...
192.168.0.224 .. 192.168.0.239
192.168.0.240 .. 192.168.0.255

Or sevaral different sizes, one section of 16, another of 32, another 64, andother 32, another 16, etc, until you have used up the 256 values available. I won't even try to enumerate the addresses for that combination at 20 to midnight.

--
Mats

12. ## The trick to find out network mask?

It would depend on the requirement in terms of 2,4, ....

if you need to give four in a class c ips then 255.255.255.252 would be the subnet mask

am i right ..?

13. Yes. 252 on the end would give you 4 addresses.

--
Mats