Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Web Development
Expertise: Beginner
Mar 18, 1997



How to Help Your Business Become an AI Early Adopter

How do subnet masks work?

What do subnet masks mean and how do they work?

Subnetworks help improve performance, reduce congestion, enhance security and allow us to isolate networks. On a wide area network, typically each local area network is a subnet. Sometimes, a LAN can be configured to be two or more subnets.

On an IP internetwork, an address takes the form of a 32-bit number, for instance:

An IP address can be viewed as follows:

If we were referring to a Class B address in the above example, the network portion of the address would have read: 135.200.

On the other hand, if a Class C was the case, 135.200.45 would have constituted the network portion.

A subnetwork mask is also a 32-bit number that indicates the composition of a IP internetwork; i.e. it reveals how many bits form the network portion and how many bits form the host portion.

Consider the following subnet mask:

FF.FF.FF.0 in hexadecimal, or in decimal.
In binary, this number would read:
Note that the first 24 bits are all 1s (such a subnet is sometimes referred to as a 24-bit mask). This indicates that the first 24 bits of the IP address refer to the network portion, and the trailing eight bits refer to the host portion. Therefore we can have a maximum number of 254 hosts per subnet; in the above example it would be through

In order to decipher network and host portions of an IP address (we assume a Class B address and subnet mask in this example), the following procedure is used:

A logical AND operation is performed between the IP address and subnet mask. For instance: and

In binary, this would be:

resulting in:
which is:
Therefore the subnet number is 45 and the network is 135.200.
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date