A subnet mask is 32-bit long of 4 times 8 octets. It has two parts: one specifying the network and the other the host. The network part has all 1s and the host all 0s. All this combination identifies a unique device on the network.
A break down of a class C subnet mask would be what is shown in the figure below:
The subnet mask clearly specifies the part of an IP address that defines the network and the part that defines the hosts. As shown in the picture above, the 255 address is always assigned to the network and the 0 is always assigned to the host.
The class C subnet mask has the first 3 octets for the network and the last octet for the hosts. It then looks like this: 255.255.255.0. It is normally use for small networks with up to 254 hosts.
The class B subnet mask has the first 2 octets for the network and the last 2 for the hosts. A class B subnet mask then looks like this: 255.255.0.0
The class A subnet mask has only the first octet for the network and the last 3 for the hosts. A class A subnet mask then looks like this: 255.0.0.0. It is usually used for large networks with a large number of hosts up to more than 65,534 hosts.
In case there is communication between different networks of an organization, the subnet mask would help assign each office network a specific network ID to avoid IP address conflicts during communication. In this case, each network will need a router with default gateway.
In case you are new to networking, a router is a network device that transmits data based on its routing table information and IP address. A router can be used to connect two separate networks and can provide secure connection between the connected networks.
Default Gateway is the router’s IP address included in the network settings of a networked host to be able to communicate to other hosts outside the local network on another subnet or the internet.