What does /16,/24 mean with regards to ip addresses?
I am trying to understand how network topologies work in large scale networks such as college campuses.
I often see the phrases /16,/24 with regards to ip addresses.
I would like to know what /16 and /24 etc. mean. I understand it has something to do with subnet masks, but my question is different.
Let's say one of /24 ip address is 124.125.126.* with subnet mask 255.255.255.0, and it can have 256-2 hosts.
I am assuming we are talking about public ips here.
What does hosts mean here? Is it 254 router can be assigned public ips here? We don't assign public ips to end user devices, they only get private ips. so I am confused what does hosts refer to here?
Solution 1:
/16, /24 is called CIDR notation, it's a different way to express the subnet mask.
A subnet mask can be used for any IP, public, private, etc.; the /X has nothing do really whether the IP is public or private.
Electronic equipment processes IP addresses as a string of 32 bits that can either be 1 or 0. It only cares about the 1's and 0's; writing it as decimal numbers is for our benefit, not any router, computer, phone, etc.
The 4 decimal numbers in an IPv4 is just a shorter way to write them so we don't have to write all the 0's and 1's.
The way the 4 decimal numbers relate to those 0's or 1's is like the below. Wherever there is a 1, add that number to that set of 8 bits to get the decimal number for that "octet".
1 1 1 1
2 6 3 1 2 6 3 1 2 6 3 1 2 6 3 1
8 4 2 6 8 4 2 1 . 8 4 2 6 8 4 2 1 . 8 4 2 6 8 4 2 1 . 8 4 2 6 8 4 2 1
--------------- . --------------- . --------------- . ---------------
1 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1
--------------- . --------------- . --------------- . ---------------
192 . 168 . 0 . 5
Net masks are always a long string of 1's followed by a long string of 0's. It determines what part of the IP identifies the network (the 1's) and what part identifies the computer/phone/host/etc.
That works like this:
1 1 1 1
2 6 3 1 2 6 3 1 2 6 3 1 2 6 3 1
8 4 2 6 8 4 2 1 . 8 4 2 6 8 4 2 1 . 8 4 2 6 8 4 2 1 . 8 4 2 6 8 4 2 1
--------------- . --------------- . --------------- . ---------------
1 1 1 1 1 1 1 1 . 1 1 1 1 1 1 1 1 . 1 1 1 1 1 1 1 1 . 0 0 0 0 0 0 0 0
--------------- . --------------- . --------------- . ---------------
255 . 255 . 255 . 0
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
--------------- . --------------- . --------------- . ---------------
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ *
or /24
CIDR just says we can simply say the number of 1 bits without writing out the four decimal numbers of the subnet mask. So you can write 192.168.0.5/24 instead of 192.168.0.5/255.255.255.0.
Solution 2:
I would like to know what /16 and /24 etc. mean. I understand it has something to do with subnet masks, but my question is different.
You could even say that it literally is a different way of writing the same subnet mask.
All valid subnet masks consist of a series of 1-bits followed by 0-bits (no mixing), so 255.255.255.0 is commonly written as /24 because it has twenty-four 1-bits. (Similarly /16 equals 255.255.0.0.)
(This number also directly corresponds to the length of the "network part" of the address, so it is often called the 'prefix length'.)
I am assuming we are talking about public ips here.
Actually that's irrelevant. Routing and subnetting work identically with private and public addresses.
(The only thing that even makes 10.x or 192.168.x "private" is policy – all ISPs and operators have agreed to never route it between each other, in accordance to RFC1918. Other than that, they're normal addresses.)
What does hosts mean here? Is it 254 router can be assigned public ips here? We don't assign public ips to end user devices, they only get private ips.
No. Any device can be assigned any kind of IP address; it does not have to be a router. The only technical reason end user devices usually get private IPs is because the network simply doesn't have enough public ones.
However, if the network does have enough public IP addresses for its needs, it can perfectly well assign them directly to hosts. (That's usually done with servers in particular, but there's nothing that would technically prevent any random PC or even a phone from being directly assigned a public IP address.)
So when the text says "hosts", it means "any kind of IPv4-speaking devices".