TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
 Specialized Dev Zones Research Center eBook Library .NET Java C++ Web Dev Architecture Database Security Open Source Enterprise Mobile Special Reports 10-Minute Solutions DevXtra Blogs Slideshow

Language: Web Development
Expertise: Beginner
Mar 18, 1997

### WEBINAR:On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning

# How do subnet masks work?

Question:
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: 135.200.45.90

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
255.255.255.0 in decimal.
In binary, this number would read:
11111111.11111111.11111111.00000000
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 135.200.45.1 through 135.200.45.254.

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: 135.200.45.254 and 255.255.255.0.

In binary, this would be:

```10000111.11001000.00101101.11111110
AND
11111111.11111111.11111111.00000000
resulting in:
10000111.11001000.00101101.00000000
which is:
135.200.45.0```
Therefore the subnet number is 45 and the network is 135.200.
DevX Pro

 Submit a Tip Browse "Application Design" Tips Browse All Tips
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