Lets say there are two public IP addresses. One is 21.120.12.8/16 and the other is 21.120.12.8/8, they are different network IDs but when used over the internet how are they both differentiated? Or is it that classful addressing is used for public IPs and classless is used for private?
1 Answers
They're not differentiated. The subnet size - or prefix length - is only relevant for routing table entries (which each carry a length field) or for a locally connected subnet where the host is configured with a specific netmask (statically or by DHCP).
One is 21.120.12.8/16 and the other is 21.120.12.8/8, they are different network IDs
While both describe differently sized networks, the address is the same. The /16 network is just a subnet of the /8 network.
A subnet mask isn't ever detected. For a pure address the mask is simply irrelevant. An end-node host only needs to know its own subnet prefix length which is either statically configured or by DHCP. Route entries on a router (or on a host for that matter) are also either statically configured by the admin or learned via a routing protocol like OSPF or RIPv2, where the mask lengths are passed along as well.
Classful networking was obsoleted in 1993 by RFC 1518. Note that even when classful networking was used, different netmask sizes were possible - they just defaulted to their class length (and were handed out by the RIRs that way).
-
"The /16 network is just a subnet of the /8 network.". So then how would classless addressing work cause it seems that the network with the lowest number of network ID bits would always subnet the ones with higher number of network ID bits. There definitely seems like I'm misunderstood, can you please explain further. – piny88 Feb 20 '21 at 23:11
-
1@piny88, those two addresses are the same, and it is all 32 bits. Masks are for routing. At least one of the hosts is misconfigured. – Ron Maupin Feb 20 '21 at 23:13
-
@piny88 It's the network with the highest number of ID bits (prefix length) that is the subnet of the one with any lower number of mask bits and where those address bits match. 10.0.2.0/24 is a subnet of 10.0.0.0/16 (the host bits must be 0 for a network address). For excellent explanations on subnetting see this question. – Zac67 Feb 21 '21 at 08:10
192.0.2.0/24
,198.51.100.0/24
, and203.0.113.0/24
. – Ron Maupin Feb 20 '21 at 22:59