Search

What is Subnet Mask

As explained in previous lesson about IPv4 addresses, an IPv4 address is a 32-bit binary number used to identify a computer uniquely in an IPv4 based TCP/IP network. IPv4 addresses are expressed as four 8-bit (4 * 8 = 32 bits) numbers, separated by a dot. Each 8-bit part is called as an octet. Example of an IPv4 address is 172.16.0.100.

What is subnet mask? Subnet mask is also a 32-bit binary number. Subnet mask is also expressed as four 8-bit (4 * 8 = 32 bits) numbers, separated by a dot. Example of a subnet mask is 255.255.0.0.

A 32-bit IPv4 address (example: 172.16.0.100) is further divided into a network part and a host part. We need a mechanism to separate an IPv4 address to a network part and a host part. Network part is used to identify the network that the computer belongs to and the host part is a unique identifier of that computer within the network. If you express an IPv4 address as plain as 172.16.0.100, there is no way to identify which is the network part and which is the host part.

To identify which part of an IPv4 address is the network part and which part of the IPv4 address is host part, we need another identifier called as "subnet mask". The purpose of the subnet mask is to identify which part of an IPv4 address is the network part and which part is the host part.

Below image shows the default subnet masks for Class A, Class B and Class C IPv4 networks.

default-subnet-masks.jpg

Please note below points.

Consider below example of two Class B neworks. Two computers with IPv4 addresses 172.16.0.100/255.255.0.0 172.17.0.100/255.255.0.0 as shown in below image belong to two different networks, 172.16.0.0 and 172.17.0.0 network respectively. Computers located in different networks cannot communicate directly in IPv4. You need a router to communicate between two different IPv4 networks. Please refer below image, which shows two different Class B networks connected together by routers.

ipv4-networks.jpg

We have two networks in above image, connected together by routers. As marked, the network address of one network ("Network 1") is 172.16.0.0 with a subnet mask of 255.255.0.0 and the network address of other network ("Network 2") is 172.17.0.0 with a subnet mask of 255.255.0.0.

Wherever "255" octet appears in the subnet mask, corresponding octet in IPv4 address belongs to the network part. Wherever "0" appears in the subnet mask, corresponding octet in IPv4 address belongs to the host part. In other words, "172.16" is the network address of "Network 1" and "172.17" is the network address of "Network 2". Please note that the previous example is shown in decimals but actual calculations are done using binary numbers.

Next paragraph explains above concept using binary numbers.

  • Wherever binary number "1" appears in subnet mask, corresponding bit in IPv4 address is the network part.
  • Wherever binary number "0" appears in subnet mask, corresponding bit in IPv4 address is the host part.

Please refer below two images to get more clear view about how subnet masks work for 172.16.0.0 and 172.17.0.0 network addresses. Please note that all host part are "0" for network addresses.

subnet-mask-network-address-1.jpg

subnet-mask-network-address-2.jpg

Please refer below two images to get more clear view about how subnet masks work for IPv4 addresses; 172.16.0.100 and 172.17.0.100.

ipv4-address-subnet-mask-1.jpg

ipv4-address-subnet-mask-2.jpg

You have learned the concept of subnet masks in IPv4 and default subnet masks for Class A, Class B and Class C IPv4 networks. Click "Next" link below to continue.

Related Tutorials
Introduction to TCP/IP, Features of TCP/IP, TCP/IP History, What is RFC (Request for Comments)
Seven Layers of OSI Model and functions of seven layers of OSI model
Five layered TCP/IP model
Network Layer (Layer 3)
TCP/IP Data Encapsulation and Decapsulation
Datalink Layer (Layer 2)
Ethernet Frame Format
What is MAC address or Layer 2 address or physical address
IPv4 Protocol, IPv4 header and fields of IPv4 header
IPv4 addresses, IPv4 Address Classes, IPv4 Address Classifications
What is Subnet Mask
What is network address
Limited broadcast address
Directed broadcast address
What is limited broadcast in IPv4 and how limited broadcast works
What is directed broadcast in IPv4 and how directed broadcast works
What is default gateway
What are private IP addresses - RFC 1918 private addresses
APIPA Addresses (Automatic Private IP Addresses)
What is loopback address in IPv4
What is localhost
Class A networks and Class A IP addresses
Class B networks and Class B IP addresses
Class C networks and Class C IP addresses
Class D multicast IP addresses
Subnetting - Part 1
Subnetting - Part 2
Subnetting - Part 3
Subnetting - Part 4
Subnetting - Part 5
Subnetting - Part 6
Variable Length Subnet Masking, VLSM, IP V4 Subnetting, subnetting tutorials, IP study guides, IP documentation, IP tutorials
Supernetting, IP Supernetting, IP Supernetting tutorial, How to Supernet, Supernetting Guide, Supernetting Concepts
How to find out the Network Address and Broadcast Address of a subnetted IPv4 address
Address Resolution Protocol Tutorial, How ARP work, ARP Message Format
What is Gratuitous ARP