Eli5 – Subnet Mask

1.46K views

Hello, i know this question has been asked numerous times, but it never managed to truly explain it, and it’s quite frustrating.

So far i understand that a Subnet Mask is used to divide an internal IP address into a Network Portion and a Host Portion. I’ll make the SOHO example because that’s what i’m used to, never saw other networks.

My internal IP is [192.168.1.1](https://192.168.1.1) and the subnet mask would then be [255.255.255.0](https://255.255.255.0).

This would mean that only 254 hosts are possible in my network, right? Since the 1 is the Default Gateway and the last would be the Broadcast Domain.

I still don’t get the point in having a mask.

It is my understanding that when forwarding a frame, the gateway would AND the 2 things:

11111111.11111111.11111111.00000000 &

11000000.10101000.00000001.00000001

the result would be

11000000.10101000.00000001.00000000 ([192.168.1.0](https://192.168.1.0))

It’s all fine and dandy but… i don’t get why? Is this somewhat like an IF statement?

e.g. IF the first 24 bits are 192.168.1, THEN it’s inside this network? But why the extra mask then?

Also because with that logic, all internal IP addresses would then become [192.168.1.0](https://192.168.1.0)

​

The IP address range 192.168.1 is already private, why do i need another set of 32 bits for the subnet mask? 192.168.1 is already my inside network, so… it’s obvious that 1 would be my default gateway, i would be 2 and so on…

Is the subnet mask just a way to “make it obvious” to the router?

I really don’t get the sense of it, probably looking at it all wrong.

Thanks in advance

​

​

EDIT: Does it mean that in the routing table, my private IP is also associated to a subnet host? E.g. [255.255.255.4](https://255.255.255.4)? Because running ipconfig i don’t recall seeing my host address.

In: Technology

7 Answers

Anonymous 0 Comments

So I was setting up a site to site VPN and I needed traffic addressed to certain IPs to access a different router. Most of the time the traffic will use the “default gateway” as the router. But I needed any traffic addressed to the 172.17.0.0-172.17.255.255 range to go to a different router.

the command to do that was

route -p add 172.17.0.0 MASK 255.255.0.0 192.168.11.11

(where 192.168.11.11 is the router I want that traffic forwarded to)

Suppose I only wanted this range forwarded 172.17.0.0-172.17.0.255 (this is 8 bits instead of 16, only 254 addresses)

now the command becomes

route -p add 172.17.0.0 MASK 255.255.255.0 192.168.11.11

The subnet mask is being used to identify the range of the network.

http://jodies.de/ipcalc

This is a tool I use a lot.

You are viewing 1 out of 7 answers, click here to view all answers.