A subnet mask is a 32-bit number that separates an IP address into two parts: the network ID and the host ID. It tells devices which portion of the address belongs to the network and which identifies individual devices. By doing this it helps to determine which devices belong to the same local network and which devices reside on different networks. It supports efficient network organization, better control of data flow and overall improved security and management of the network.
For example:
Role of Subnet MaskSubnet masks help divide a large network into smaller sub-networks (subnets), improving network efficiency, security, and performance.
Function of Subnet Mask
Why Use a Subnet Mask?
Suppose we have a Class A network which means we have 16 million hosts in a network. Managing such a large network becomes challenging due to:
- Maintenance of such a huge network.
- Security for the network – For example, we have 4 departments in a company, and all of the 4 departments need access to the whole network.
Solution: Subnetting
Subnetting solves these problems by dividing a large network into smaller, manageable sub-networks (subnets). Each department gets its own subnet, improving security and efficiency.
Without subnetting, identifying a device requires three steps:
- Identification of the network
- Identification of the host
- Identification of the process
In case of addressing with subnetting, the process of reaching an address is done by 4 steps –
- Identification of the network
- Identification of the subnet
- Identification of the host
- Identification of the process
Suppose we have a Class C network and we want to divide it into 4 subnets. To divide we need to choose 2 bits from the host part.

As the first and last IP addresses are reserved for network ID and directed broadcast address in every subnet, we have to reserve 8 IP addresses in this case.

Representation of Subnet Masks
A subnet mask is a 32-bit number made of 1s and 0s. The 1s identify the network, and the 0s represent devices (hosts) in that network. For this case subnet mask is,
11111111.11111111.11111111.11000000
or
255.255.255.192
So in order to get the network which the destination address belongs to we have to bitwise & with subnet mask.
11111111.11111111.11111111.11000000
&& 11001000.00000001.00000010.00010100
-----------------------------------------------------
11001000.00000001.00000010.00000000
The address belongs to,
11001000.00000001.00000010.00000000
or
200.1.2.0
The internal router will forward the packet to the network through an interface . The interface will be identified by the routing table residing in the router.
Routing Table and Subnet Matching
If the network id doesn’t matches with any of the subnet mask then the packet will be sent to default entry.
Default entry has network id as 0.0.0.0.

In some cases the network id may match with two entries in the routing table, so here the interface having the longest subnet mask (more 1’s) is selected.
How Does Subnetting Work
Subnetting divides a large network into smaller sub-networks by modifying the subnet mask. This improves the management of IP addresses, reduces broadcast traffic, and increases network security by isolating different parts of the network. Subnetting also helps optimize the use of IP address space and improves troubleshooting and overall network performance.
For example, subnetting can organize devices into logical groups, such as separating a company's departments into different subnets. This way, traffic within one department does not unnecessarily interfere with others, improving performance and security
Network Classes
The Internet Assigned Numbers Authority (IANA), through InterNIC, oversees the allocation of IP addresses. IP addresses are divided into classes to simplify their use, with Classes A, B, and C being the most commonly used. Classes D and E exist but are not used by end users. Each class has a default subnet mask, and the first octet of the IP address determines its class. The ranges of Class A, B, and C Internet addresses are given below, along with a sample address for each:
Range of ClassesRead more about classful IP addressing.
Advantages of Subnetting
- Reduces network congestion: Limits broadcast traffic, improving network speed.
- Efficient IP Usage: Allocates IPs based on need, avoiding wastage.
- Enhances security by isolating subnets: For example, no other department within an organization should be able to view the code created by the Developer department.
- Enables Departmental Segmentation: A higher network priority may be needed for some subnets than for others. For instance, a sales department might need to hold video conferences or webcasts.
- Supports Scalability: Allows networks to grow while remaining organized.
Disadvantages of Subnetting
- Limited IP Address Space: Dividing networks reduces available IPs per subnet.
- Additional Hardware: Subnetting reduces the overall number of IP addresses in the network, yet it could necessitate purchasing extra hardware, like a router. Thus it could be very expensive.
- Complex Setup: Requires expertise to plan and configure subnets.
- Compatibility Issues: Older devices or systems may struggle with subnetting configurations.
Similar Reads
CCNA Tutorial for Beginners This CCNA Tutorial is well-suited for the beginner as well as professionals, and It will cover all the basic to advanced concepts of CCNA like Components of Computer Networking, Transport Layer, Network Layer, CCNA training, Cisco Networking, Network Design, Routing and Switching, etc. which are req
8 min read
Basics of Computer Networking
Components of Computer Networking
NIC Full Form - Network Interface CardNIC stands for Network Interface Card. NIC is additionally called Ethernet or physical or network card. NIC is one of the major and imperative components of associating a gadget with the network. Each gadget that must be associated with a network must have a network interface card. Even the switches
4 min read
What is a Network Switch and How Does it Work?The Switch is a network device that is used to segment the networks into different subnetworks called subnets or LAN segments. It is responsible for filtering and forwarding the packets between LAN segments based on MAC address. Switches have many ports, and when data arrives at any port, the destin
9 min read
What is Network Hub and How it Works?Hub in networking plays a vital role in data transmission and broadcasting. A hub is a hardware device used at the physical layer to connect multiple devices in the network. Hubs are widely used to connect LANs. A hub has multiple ports. Unlike a switch, a hub cannot filter the data, i.e. it cannot
6 min read
Introduction of a RouterNetwork devices are physical devices that allow hardware on a computer network to communicate and interact with one another. For example Repeater, Hub, Bridge, Switch, Routers, Gateway, Router, and NIC, etc. What is a Router?A Router is a networking device that forwards data packets between computer
12 min read
Types of Ethernet CableAn ethernet cable allows the user to connect their devices such as computers, mobile phones, routers, etc, to a Local Area Network (LAN) that will allow a user to have internet access, and able to communicate with each other through a wired connection. It also carries broadband signals between devic
5 min read
Transport Layer
Transport Layer responsibilitiesThe transport Layer is the second layer in the TCP/IP model and the fourth layer in the OSI model. It is an end-to-end layer used to deliver messages to a host. It is termed an end-to-end layer because it provides a point-to-point connection rather than hop-to-hop, between the source host and destin
5 min read
Introduction of Ports in ComputersA port is basically a physical docking point which is basically used to connect the external devices to the computer, or we can say that A port act as an interface between the computer and the external devices, e.g., we can connect hard drives, printers to the computer with the help of ports. Featur
3 min read
What is TCP (Transmission Control Protocol)?Transmission Control Protocol (TCP) is a connection-oriented protocol for communications that helps in the exchange of messages between different devices over a network. It is one of the main protocols of the TCP/IP suite. In OSI model, it operates at the transport layer(Layer 4). It lies between th
5 min read
TCP 3-Way Handshake ProcessThe TCP 3-Way Handshake is a fundamental process that establishes a reliable connection between two devices over a TCP/IP network. It involves three steps: SYN (Synchronize), SYN-ACK (Synchronize-Acknowledge), and ACK (Acknowledge). During the handshake, the client and server exchange initial sequen
6 min read
User Datagram Protocol (UDP)User Datagram Protocol (UDP) is a Transport Layer protocol. UDP is a part of the Internet Protocol suite, referred to as UDP/IP suite. Unlike TCP, it is an unreliable and connectionless protocol. So, there is no need to establish a connection before data transfer. The UDP helps to establish low-late
10 min read
Network Layer
IPv4 Addressing
Subnetting
Data Link Layer
Physical Layer
Cisco Networking Devices
Network Devices (Hub, Repeater, Bridge, Switch, Router, Gateways and Brouter)Network devices are physical devices that allow hardware on a computer network to communicate and interact with each other. Network devices like hubs, repeaters, bridges, switches, routers, gateways, and brouter help manage and direct data flow in a network. They ensure efficient communication betwe
9 min read
Collision Detection in CSMA/CDCSMA/CD (Carrier Sense Multiple Access/ Collision Detection) is a media access control method that was widely used in Early Ethernet technology/LANs when there used to be shared Bus Topology and each node ( Computers) was connected by Coaxial Cables. Nowadays Ethernet is Full Duplex and Topology is
7 min read
Collision Domain and Broadcast Domain in Computer NetworkPrerequisite - Network Devices, Transmission Modes The most common network devices used are routers and switches. But we still hear people talking about hubs, repeaters, and bridges. Do you ever wonder why these former devices are preferred over the latter ones? One reason could be: 'because they ar
5 min read
Difference between layer-2 and layer-3 switchesA switch is a device that sends a data packet to a local network. What is the advantage of a hub? A hub floods the network with the packet and only the destination system receives that packet while others just drop due to which the traffic increases a lot. To solve this problem switch came into the
5 min read