The routers require subnet mask to route the packets to other routers or hosts, but why do host machines that are not routers such as computer running Ubuntu or windows need subnet mask to be configured. It does not do any routing. Where is the subnet mask used in the non-router host machine ?
-
The host machine needs to know what its own network is. Also, it does have a routing table and it does route internally. – Ron Maupin Mar 21 '20 at 17:16
2 Answers
The host's subnet mask allows it to know what addresses are on its local LAN (so it uses ARP to learn their MAC address, and sends traffic directly to them) vs what addresses are not within their subnet (for which they use their default gateway.)

- 5,469
- 10
- 19
Imagine this scenario:
Host B knows it's own IP address (10.3.3.22).
Consider, if Host B needs to speak to Host A with the IP 10.3.3.11 (which we can tell exists in the same Network as Host B because of the blue circle), Host B can speak to it directly.
But How does Host B know that? It doesn't have the luxury of a pretty topology photo and blue circle to look at like we do.
Instead, it uses the Subnet Mask. Assume it has a Subnet Mask of 255.255.255.0. Host B can do a little subnetting to determine that the IP addresses 10.3.3.0 through 10.3.3.255 are on it's own network. And from there determine that 10.3.3.11 (Host A) is indeed in this range.
This is also what tells Host B that if it needs to speak to Host D, that Host D's IP address (10.4.4.44) does NOT fall in Host B's network, and therefore the packet must be sent to the Default Gateway (i.e., the Router).
More details on the process (and where the image above came from) can be found in this video: https://www.youtube.com/watch?v=QPi5Nvxaosw
Disclaimer, I created the video, hope it helps

- 15,026
- 6
- 44
- 84
-
1Thanks for the video. Most of the tutorial on the internet does not with the arp that is missing piece of knowledge. – Talespin_Kit Mar 22 '20 at 09:03