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?

  • 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 Super User. – 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 0:11
  • 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 0:51
2

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.