0

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?

piny88
  • 1
  • Those are the same addresses. Addresses on IP packets are only the address, they do not have the mask or length. The two hosts are on the same network, but one (or both) has a misconfigured mask. Classful addressing has been dead since 1993. By the way, you should never use public addresses not assigned to you. IANA has set aside three address ranges for examples: 192.0.2.0/24, 198.51.100.0/24, and 203.0.113.0/24. – Ron Maupin Feb 20 '21 at 22:59
  • Why do you care? Under what circumstances do you need to know anything about the size of a foreign network? – Ricky Feb 20 '21 at 23:06
  • @Ricky, I'm trying to understand how classless addressing works, but its really confusing since it seems that there could be different networks that look the same but have a different subnet mask. – piny88 Feb 20 '21 at 23:08
  • 1
    An address is an address. Masks are for routing. There is a section in this two-part answer that explains how to tell if two addresses are in the same network. Use the shortest mask. – Ron Maupin Feb 20 '21 at 23:11
  • See also: https://networkengineering.stackexchange.com/questions/64515/cidr-and-vlsm-what-are-the-differences – Jeff Wheeler Feb 22 '21 at 13:00
  • Did any answer help you? if so, you should accept the answer so that the question does not keep popping up forever, looking for an answer. Alternatively, you could post and accept your own answer. – Ron Maupin Dec 23 '21 at 16:51

1 Answers1

2

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).

Zac67
  • 84,333
  • 4
  • 69
  • 133
  • "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