Score:0

How does a machine know what subnet it's on?

cn flag

There is a good explanation on how subnets work generally, but how is the information of what subnets exist, what are the available network IDs, and what subnet a machine is on, sent to the router and the machines on a network? Is it via a protocol?

How does IPv4 Subnetting Work?

Jaromanda X avatar
ru flag
If you set a static IPv4 address, you set IP address and network mask etc - so, how does it know? Easy. You set it. If the IP address is obtained via DHCP, then it's DHCP that sets not only the IP address but the netmask etc. So, how does it know? DHCP set it
T. Webster avatar
cn flag
@JaromandaX Thank you! This is what I needed.
paladin avatar
id flag
Additional to that, if you are able to not provide a subnetmask, it may be possible that the network software assumes a classful network configuration -> https://en.wikipedia.org/wiki/Classful_network , but this "feature" is often mostly integrated for backwards compatibility. In example, setting the IP to 10.0.0.1 but not setting any subnetmask (if the software allows you to not setting up a subnetmask), might result into subnetmask 255.0.0.0 .
Score:1
cn flag

IPv6 is easier in that there is a well-defined protocol, and you can forget about counting hosts.

Router advertisements (RA) are multicast from routers to announce themselves. Attached prefix information defines one or more prefixes, with an L bit set for hosts that are known to be on-link.

RA source IP address is a link local address, which cannot be routed and thus must be on-link. Hosts can use this address as a default route.

A default gateway may send a redirect telling senders that a destination is actually on-link, and can be sent there directly.

There should exist a means to manually set a prefix as on-link.

That's all, these fully define what hosts are on this layer 2 and which are at least one router away.

This is of course only the basics about host networking. Prefixes are also communicated with DHCP PD, or routing protocols.

Further reading: Russ White on on-link,
rfc 5942 IPv6 Subnet Model: The Relationship between Links and Subnet Prefixes


Regarding right-sizing prefixes to number of hosts, do not bother. The smallest reasonable size prefix is /64 which is effectively unlimited.

Lest you be concerned that you learned that binary math for nothing, it is still useful in address planning. Now the question becomes, will the number of nets your business unit need exceed the number of /64s in a /48.

Jaromanda X avatar
ru flag
Did I miss something? How is this answer relevant to IPv4?
John Mahowald avatar
cn flag
The question was not restricted to IPv4. I suppose I could have contrasted it to IPv4 having only same network address comparison, but did not.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.