3

I have a question regarding subnet masks and my understanding (or misunderstanding of them).

So when a subnet mask is used, a bitwise AND is performed using the subnet mask and the IP address(es). Traffic is exchanged (routed) between subnetworks with special gateways (routers) when the routing prefixes of the source address and the destination address differ. A router constitutes the logical or physical boundary between the subnets.

OK so far. But surely on everything has to be sent to a router/switch anyway right? So why do you need to have the subnet mask on your computer? If all data goes through the router, surely it is only the router that needs to have the subnet mask on it?

Ron Maupin
  • 99,565
  • 26
  • 120
  • 195
Robert Flook
  • 231
  • 3
  • 5
  • Unfortunately, questions about home networking are explicitly off-topic here. – Ron Maupin May 16 '16 at 22:26
  • 1
    Actually scratch that, it doesnt matter if it is a home network - it could be any routing device really. The question remains the same - will edit my question to remove reference to home network – Robert Flook May 16 '16 at 22:26
  • I'm working on a general answer for you, but home networking questions can be asked on [su]. – Ron Maupin May 16 '16 at 22:28
  • 2
    @RonMaupin This is very squarely a Networking question, and therefore on topic. It is irrelevant if the application of the answer is a home network, or an enterprise network, or geek trivia night at the local bar. – Eddie May 17 '16 at 00:11
  • @Eddie, he fixed it to remove the question about home networking. I answered the question, and I didn't vote to close it. I explained that I was answering it from a general perspective. The original question, and the remnants (router/switch combination), don't really fit the answer. I don't see the problem. – Ron Maupin May 17 '16 at 00:15
  • 2
    @RonMaupin Just trying to make sure we keep the community welcoming. And not make it an exercise on avoiding key words, but on asking honest questions. – Eddie May 17 '16 at 00:51
  • I was just trying to keep the question on-topic. and things worked the way they are supposed to work. The question got fixed, and it got an answer. All that happened without any intervention from you, and your comments did nothing but inflame the situation. – Ron Maupin May 17 '16 at 01:01
  • Did any answer help you? if so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you could provide and accept your own answer. – Ron Maupin Aug 12 '17 at 19:07

1 Answers1

3

What a mask does is to define the separation between the network portion of an address, and the host portion of an address. IPv4 lets you slide these two pieces around to get a network which has enough host addresses to match your needs. This answer may help you to visualize this.

You can also use shorter masks to aggregate or summarize networks. This allows you to advertise a single route instead of a bunch of smaller routes.

But surely on everything has to be sent to a router/switch anyway right? So why do you need to have the subnet mask on your computer? If all data goes through the router, surely it is only the router that needs to have the subnet mask on it?

Not everything needs to be sent to a router. Traffic destined for the same network will never go through the router. Switches don't count since they don't participate in layer-3, where IP is.

When a host wants to send something to another host, it masks the destination address to see if it is on the same network as itself. If it is, it just sends the traffic directly to the host on the same network. If the destination is on another network, it sends the traffic to its configured gateway. It does this using layer-2 (e.g. MAC) addresses, not by changing the destination IP address.

With IPv6, you basically have a single network size (/64), so much of address manipulation is easier.

Ron Maupin
  • 99,565
  • 26
  • 120
  • 195